1

在 .net 中使用 DirectorySearcher 的 FindAll() 方法时,SearchResultCollection 的 GetDirectoryEntry() 方法是否需要再次访问 Active Directory?例如...

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

2 回答 2

1

根据文档,它将重新查询 AD 以获取目录条目。

参考

当您要查看实时条目而不是通过 DirectorySearcher 返回的条目时,或者要在返回的对象上调用方法时,请使用 GetDirectoryEntry。

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

于 2009-07-16T02:40:31.857 回答
0

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

于 2009-07-16T05:40:01.740 回答