共用方式為


DirectoryEntry.Username 屬性

定義

取得或設定要在驗證用戶端時使用的使用者名稱。

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

屬性值

驗證用戶端時所要使用的使用者名稱。

屬性

範例

下列範例示範 Username 類別的 DirectoryEntryPassword 屬性。 這個範例會取得使用者指定的 DirectoryEntry ,以及 Path 所有 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);  
}  

備註

您可以設定 UsernamePassword ,以指定要用來存取 Active Directory 網域服務 資訊的替代認證。 例如,從這個實例擷取的任何其他 DirectoryEntry 物件 (,都會 Children 使用相同的替代認證自動建立) 。

適用於

另請參閱