次の方法で共有


DirectoryEntry.Password プロパティ

クライアントの認証時に使用するパスワードを取得または設定します。

Public Property Password As String
[C#]
public string Password {get; set;}
[C++]
public: __property String* get_Password();public: __property void set_Password(String*);
[JScript]
public function get Password() : String;public function set Password(String);

プロパティ値

クライアントの認証時に使用するパスワード。

解説

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

使用例

[Visual Basic, C#, C++] DirectoryEntry クラスの Username プロパティと Password プロパティの例を次に示します。この例は、ユーザーが指定した DirectoryEntry 、およびそのすべての ChildrenPath を取得します。

 
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 

[C#] 
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);

[C++] 
String* myADSPath = S"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(S"The Child ADS objects are:");
Collections::IEnumerator* myEnum = myDirectoryEntry->Children->GetEnumerator();
while (myEnum->MoveNext()) {
    DirectoryEntry* myChildDirectoryEntry = __try_cast<DirectoryEntry*>(myEnum->Current);
    Console::WriteLine(myChildDirectoryEntry->Path);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

DirectoryEntry クラス | DirectoryEntry メンバ | System.DirectoryServices 名前空間 | Children | Username | AuthenticationType