DirectoryEntry.Username Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece el nombre de usuario que se va a usar para autenticar el 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 de propiedad
El nombre de usuario que se va a utilizar al autenticar al cliente.
- Atributos
Ejemplos
En el ejemplo siguiente se muestran las Username propiedades y Password de la DirectoryEntry clase . En este ejemplo se obtiene el especificado por el usuario DirectoryEntry y el Path de todos sus .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);
}
Comentarios
Puede establecer y UsernamePassword para especificar credenciales alternativas con las que acceder a la información de Servicios de dominio de Active Directory. Los demás DirectoryEntry objetos recuperados de esta instancia (por ejemplo, a través Childrende ) se crean automáticamente con las mismas credenciales alternativas.