Compartilhar via


SearchResult.GetDirectoryEntry Método

Definição

Recupera o DirectoryEntry que corresponde ao SearchResult da hierarquia do Active Directory Domain Services.

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

Retornos

O DirectoryEntry que corresponde ao SearchResult.

Exemplos

O exemplo a seguir é um trecho do exemplo em SearchResult. O exemplo original cria um novo DirectoryEntry objeto com o caminho desejado e usa o FindOne método para iniciar a pesquisa. Depois de executar a pesquisa, o exemplo usa o GetDirectoryEntry método para recuperar a entrada de diretório dinâmico identificada nos resultados da pesquisa.

' 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);  

Comentários

Use GetDirectoryEntry quando quiser examinar a entrada dinâmica em vez da entrada que foi retornada por meio DirectorySearcherde ou quando quiser invocar um método no objeto que foi retornado.

Observação

Chamar GetDirectoryEntry em cada SearchResult retornado pode DirectorySearcher ser lento.

Aplica-se a