次の方法で共有


SearchResult.GetDirectoryEntry メソッド

Active Directory 階層から SearchResult に対応する DirectoryEntry を取得します。

Public Function GetDirectoryEntry() As DirectoryEntry
[C#]
public DirectoryEntry GetDirectoryEntry();
[C++]
public: DirectoryEntry* GetDirectoryEntry();
[JScript]
public function GetDirectoryEntry() : DirectoryEntry;

戻り値

SearchResult に対応する DirectoryEntry

解説

DirectorySearcher を通じて返されるエントリではなく、ライブ エントリを参照する場合や、返されたオブジェクトでメソッドを呼び出す場合は、 GetDirectoryEntry を使用します。

メモ    DirectorySearcher で返された SearchResult ごとに GetDirectoryEntry を呼び出すと、時間がかかることがあります。

使用例

[Visual Basic, C#, C++] 次の例は、 SearchResult の例の抜粋です。元の例は、検索条件を持つ新しい DirectoryEntry を作成し、 FindOne メソッドを使用して検索を実行します。検索結果は、 GetDirectoryEntry に格納されます。

[Visual Basic, C#, C++] この例では、 GetDirectoryEntry から検索結果を取得し、解析する方法を示します。

 
' Get the 'DirectoryEntry' that corresponds to 'mySearchResult'.
Dim myDirectoryEntry As DirectoryEntry = mySearchResult.GetDirectoryEntry()
Console.WriteLine(ControlChars.Newline + "The name of the 'myDirectoryEntry' " + _
            "directory entry that corresponds to the " + _
            "'mySearchResult' search result is : {0}" + _
            ControlChars.Newline, myDirectoryEntry.Name)

[C#] 
// Get the 'DirectoryEntry' that corresponds to 'mySearchResult'.
DirectoryEntry myDirectoryEntry = 
                           mySearchResult.GetDirectoryEntry();
Console.WriteLine("\nThe name of the 'myDirectoryEntry' " +
                  "directory entry that corresponds to the " +
                  "'mySearchResult' search result is : {0}\n",
                  myDirectoryEntry.Name);

[C++] 
// Get the 'DirectoryEntry' that corresponds to 'mySearchResult'.
DirectoryEntry* myDirectoryEntry = mySearchResult->GetDirectoryEntry();
Console::WriteLine(
    String::Concat(S"\nThe name of the 'myDirectoryEntry' ",
    S"directory entry that corresponds to the ",
    S"'mySearchResult' search result is : {0}\n"),
    myDirectoryEntry->Name);

[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 セキュリティ:

参照

SearchResult クラス | SearchResult メンバ | System.DirectoryServices 名前空間 | DirectorySearcher