DirectoryEntry.Username Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define o nome de usuário que será usado para autenticar o cliente.
public:
property System::String ^ Username { System::String ^ get(); void set(System::String ^ value); };
public string Username { get; set; }
public string? Username { get; set; }
[System.ComponentModel.Browsable(false)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.DirectoryServices.DSDescription("DSUsername")]
public string Username { get; set; }
[System.ComponentModel.Browsable(false)]
[System.DirectoryServices.DSDescription("DSUsername")]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Username { get; set; }
[System.ComponentModel.Browsable(false)]
[System.DirectoryServices.DSDescription("DSUsername")]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Username { get; set; }
member this.Username : string with get, set
[<System.ComponentModel.Browsable(false)>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
[<System.DirectoryServices.DSDescription("DSUsername")>]
member this.Username : string with get, set
[<System.ComponentModel.Browsable(false)>]
[<System.DirectoryServices.DSDescription("DSUsername")>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Username : string with get, set
[<System.ComponentModel.Browsable(false)>]
[<System.DirectoryServices.DSDescription("DSUsername")>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Username : string with get, set
Public Property Username As String
Valor da propriedade
O nome de usuário a ser usado ao autenticar o cliente.
- Atributos
Exemplos
O exemplo a seguir demonstra as Username propriedades e Password da DirectoryEntry classe . Este exemplo obtém o especificado pelo DirectoryEntry usuário e o Path de todos os seus Children.
Dim myADSPath As String = _
"LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com"
' Create an Instance of DirectoryEntry.
Dim myDirectoryEntry As New DirectoryEntry(myADSPath)
myDirectoryEntry.Username = UserName
myDirectoryEntry.Password = SecurelyStoredPassword
' Get the Child ADS objects.
Console.WriteLine("The Child ADS objects are:")
Dim myChildDirectoryEntry As DirectoryEntry
For Each myChildDirectoryEntry In myDirectoryEntry.Children
Console.WriteLine(myChildDirectoryEntry.Path)
Next myChildDirectoryEntry
String myADSPath = "LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";
// Create an Instance of DirectoryEntry.
DirectoryEntry myDirectoryEntry = new DirectoryEntry(myADSPath);
myDirectoryEntry.Username = UserName;
myDirectoryEntry.Password = SecurelyStoredPassword;
// Get the Child ADS objects.
Console.WriteLine("The Child ADS objects are:");
foreach(DirectoryEntry myChildDirectoryEntry in myDirectoryEntry.Children)
Console.WriteLine(myChildDirectoryEntry.Path);
String^ myADSPath = "LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";
// Create an Instance of DirectoryEntry.
DirectoryEntry^ myDirectoryEntry = new DirectoryEntry(myADSPath);
myDirectoryEntry->Username = UserName;
myDirectoryEntry->Password = SecurelyStoredPassword;
// Get the Child ADS objects.
Console::WriteLine("The Child ADS objects are:");
Collections::IEnumerator^ myEnum = myDirectoryEntry->Children->GetEnumerator();
while (myEnum->MoveNext())
{
DirectoryEntry^ myChildDirectoryEntry = safe_cast<DirectoryEntry^>(myEnum->Current);
Console::WriteLine(myChildDirectoryEntry->Path);
}
Comentários
Você pode definir o Username e Password para especificar credenciais alternativas com as quais acessar as informações no Active Directory Domain Services. Quaisquer outros DirectoryEntry objetos recuperados dessa instância (por exemplo, por meio Childrende ) são criados automaticamente com as mesmas credenciais alternativas.