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开发者_如何学JAVA. 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
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?)
精彩评论