Search code examples
.netperformanceactive-directorydirectoryservices

Does SearchResultCollection's GetDirectoryEntry have to query ActiveDirectory again? [DirectoryServices/.net]


When using the FindAll() method of the DirectorySearcher in .net, does the GetDirectoryEntry() method of the SearchResultCollection require another trip to Active Directory? e.g....

Dim src As SearchResultCollection
Dim ds As New DirectorySearcher
' code to setup DirectorySearcher


' go to Active Directory and fill collection with results
src = ds.FindAll()

'...later on in code or whatever
' does the next line of code require another trip to Active Directory?
Dim de As DirectoryEntry = src.item(0).GetDirectoryEntry()

Solution

  • According to the documentation it will requery AD to get the directory entry.

    Reference

    Use GetDirectoryEntry when you want to look at the live entry instead of the entry that was returned through DirectorySearcher, or when you want to invoke a method on the object that was returned.

    Note: Calling GetDirectoryEntry on each SearchResult returned through DirectorySearcher can be slow.