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

末鹿安然 提交于 2019-12-11 12:32:45

问题


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()

回答1:


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.




回答2:


Yes, it will go back to AD and get the whole DirectoryEntry object.

If you want to avoid this (and you should, whenever possible), specify those properties you really need on your DirectorySearcher using the PropertiesToLoad collection, and then inspect the SearchResult.Properties for those values - those will be returned with the search and do not require yet another roundtrip to the Active Directory.

Marc



来源:https://stackoverflow.com/questions/1135155/does-searchresultcollections-getdirectoryentry-have-to-query-activedirectory-ag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!