目录搜索器 SearchResultCollection.count 非常慢

发布于 2024-10-17 15:46:11 字数 647 浏览 2 评论 0原文

我有一个正在寻找动态组的目录搜索器。 当我尝试处理结果时,需要 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞陪衬 2024-10-24 15:46:11

在进入循环之前是否绝对有必要检查计数?难道您不能只检查以确保结果不为空,然后迭代那里的任何内容吗? (既然你说你在计数检查之后有一个处理“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?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文