SearchResult.GetDirectoryEntry 方法

定义

从 Active Directory 域服务层次结构检索与 SearchResult 相对应的 DirectoryEntry

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

返回

DirectoryEntry 对应的 SearchResult

示例

以下示例是 中 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);  

注解

如果要查看实时条目而不是通过 DirectorySearcher返回的条目,或者想要对返回的对象调用方法,请使用 GetDirectoryEntry

注意

对返回的每个SearchResult通过 DirectorySearcher 的调用GetDirectoryEntry可能会很慢。

适用于