共用方式為


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

傳回

對應到 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傳回的專案,或想要在傳回的物件上叫用方法時,請使用 。

注意

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

適用於