2011-02-15 76 views
0

我有一个目录搜索器正在寻找动态组。 当我尝试处理结果时,需要30秒才能返回结果。 ds.findall速度非常快,但是当我试图找出返回的记录数量 或任何有关结果的记录时,需要30秒。所以我认为这是信息的实际复现发生的地方。为什么需要这么长时间,有没有办法加快速度。代码如下。目录搜索器SearchResultCollection.count非常慢

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 

回答

0

在进入循环之前检查计数是否绝对必要?难道你不能只是检查,以确保结果不为空,然后遍历那里? (既然你说在Count检查之后你有一个处理'For'循环,为什么要用一个额外的时间来计算连接以获得计数?)

+0

我发现问题是动态组。它必须扩展动态组中的所有用户,以查看我正在寻找的用户是否在其中。当我们添加了美眉和更多动态组合时,这变得难以管理。 – Boz 2011-02-24 21:43:18