SearchResult.GetDirectoryEntry 方法

定義

從 Active Directory 網域服務階層架構中擷取對應至 DirectoryEntrySearchResult

public:
 System::DirectoryServices::DirectoryEntry ^ GetDirectoryEntry();
public System.DirectoryServices.DirectoryEntry GetDirectoryEntry ();
member this.GetDirectoryEntry : unit -> System.DirectoryServices.DirectoryEntry
Public Function GetDirectoryEntry () As DirectoryEntry

傳回

DirectoryEntry

對應到 DirectoryEntrySearchResult

範例

下列範例是中的範例摘要 SearchResult 。 原始範例會使用所 DirectoryEntry 需的路徑建立新的物件,並使用 FindOne 方法來起始搜尋。 執行搜尋之後,此範例 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)  
// 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);  
// Get the 'DirectoryEntry' that corresponds to 'mySearchResult'.  
DirectoryEntry^ myDirectoryEntry = mySearchResult->GetDirectoryEntry();  
Console::WriteLine(  
    String::Concat("\nThe name of the 'myDirectoryEntry' ",  
    "directory entry that corresponds to the ",  
    "'mySearchResult' search result is : {0}\n"),  
    myDirectoryEntry->Name);  

備註

GetDirectoryEntry當您想要查看即時專案,而不是透過傳回的專案 DirectorySearcher ,或當您想要在傳回的物件上叫用方法時,請使用。

注意

GetDirectoryEntry在每個傳回的上呼叫 SearchResult DirectorySearcher 可能會很慢。

適用於