DirectoryEntry.Username プロパティ
アセンブリ: System.DirectoryServices (system.directoryservices.dll 内)

Dim instance As DirectoryEntry Dim value As String value = instance.Username instance.Username = value
/** @property */ public String get_Username () /** @property */ public void set_Username (String value)
クライアントの認証時に使用するユーザー名。

Username と Password を設定して、Active Directory の情報にアクセスするための代替的な資格情報を指定できます。このインスタンスから (たとえば、Children を使用して) 取得したその他の DirectoryEntry オブジェクトは、同じ代替的な資格情報で自動的に作成されます。

DirectoryEntry クラスの Username プロパティと Password プロパティの例を次に示します。この例は、ユーザーが指定した DirectoryEntry、およびそのすべての Children の Path を取得します。
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); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DirectoryEntry.Username プロパティのページへのリンク