SearchResultCollection 的 GetDirectoryEntry 是否必须再次查询 ActiveDirectory? [目录服务/.net]
在 .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()
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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据文档,它将重新查询 AD 以获取目录条目。
参考
According to the documentation it will requery AD to get the directory entry.
Reference
是的,它会返回AD并获取整个DirectoryEntry对象。
如果您想避免这种情况(只要可能,您就应该这样做),请使用
PropertiesToLoad
集合在DirectorySearcher
上指定您真正需要的属性,然后检查这些值的 SearchResult.Properties
- 这些值将随搜索返回,并且不需要再次往返 Active Directory。马克
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 thePropertiesToLoad
collection, and then inspect theSearchResult.Properties
for those values - those will be returned with the search and do not require yet another roundtrip to the Active Directory.Marc