目录搜索器 SearchResultCollection.count 非常慢
我有一个正在寻找动态组的目录搜索器。 当我尝试处理结果时,需要 30 秒才能返回结果。 ds.findall 非常快,但是当我尝试找出返回的记录数时 或者任何关于结果的事情都需要 30 秒。所以我假设这就是实际检索信息的地方。为什么需要这么长时间,有没有办法加快速度。代码如下。
query = "(&(objectClass=dynamicgroup)(member=cn=mvander,ou=reg,ou=Employees,ou=staff,o=wpsr))"
Dim results As SearchResultCollection
Dim result As SearchResult
entry = GetValidDirectoryEntry(searchRootAdsPath, True)
ds = New DirectorySearcher(entry)
ds.PropertiesToLoad.Add(attributesToQuery("GroupMembership"))
results = ds.FindAll
'This line takes up to 30 seconds to return the results
If results.Count > 0 Then
'I have a for each loop that processes the results
I have a directory searcher that is looking for dynamic groups.
When I try to process the results it is taking 30 seconds to return the results.
the ds.findall is very fast but when I try to find out the number of records returned
or anything about the results it take the 30 seconds. So i am assuming that this is where the actual retreival of information is taking place. Why does it take so long and is there a way to speed it up. Code is below.
query = "(&(objectClass=dynamicgroup)(member=cn=mvander,ou=reg,ou=Employees,ou=staff,o=wpsr))"
Dim results As SearchResultCollection
Dim result As SearchResult
entry = GetValidDirectoryEntry(searchRootAdsPath, True)
ds = New DirectorySearcher(entry)
ds.PropertiesToLoad.Add(attributesToQuery("GroupMembership"))
results = ds.FindAll
'This line takes up to 30 seconds to return the results
If results.Count > 0 Then
'I have a for each loop that processes the results
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在进入循环之前是否绝对有必要检查计数?难道您不能只检查以确保结果不为空,然后迭代那里的任何内容吗? (既然你说你在计数检查之后有一个处理“For”循环;为什么要额外枚举连接时间来获取计数?)
Is it absolutely necessary to check the count before entering the loop? Can't you just check to make sure that results is not null, then iterate over whatever is there? (Since you say that you have a processing 'For' loop following the Count check anyway; why enumerate the connection an extra time to get the count?)