DirectoryEntry.Username DirectoryEntry.Username DirectoryEntry.Username DirectoryEntry.Username Property

定義

クライアントの認証時に使用するユーザー名を取得または設定します。Gets or sets the user name to use when authenticating the client.

public:
 property System::String ^ Username { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.DirectoryServices.DSDescription("DSUsername")]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Username { get; set; }
member this.Username : string with get, set
Public Property Username As String

プロパティ値

クライアントの認証時に使用するユーザー名。The user name to use when authenticating the client.

クラスのPassword Username プロパティとプロパティを次の例に示しますDirectoryEntryThe following example demonstrates the Username and Password properties of the DirectoryEntry class. この例では、ユーザーがDirectoryEntry指定しPathたと、 Childrenそのすべてのを取得します。This example gets the user-specified DirectoryEntry and the Path of all its 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 Domain Services の情報にアクセスするための代替資格情報を指定できます。You can set the Username and Password in order to specify alternate credentials with which to access the information in Active Directory Domain Services. このインスタンスDirectoryEntryから取得したその他のオブジェクト ( Childrenなど) は、同じ代替資格情報で自動的に作成されます。Any other DirectoryEntry objects retrieved from this instance (for example, through Children) are automatically created with the same alternate credentials.

適用対象

こちらもご覧ください