Hi Folks,
I am having a similar issue as mentioned Here in that a query for users name beginning with 'G' just brings back a set of random results (actually I get 10 records sorted into alphabetical order starting from 'A').
DirectorySearcher search = new DirectorySearcher(directoryEntry); search.SearchRoot = null; search.Asynchronous = false; search.Filter = String.Format("(objectClass=User)"); SortOption sortOption = new SortOption() { Direction = SortDirection.Ascending, PropertyName = "displayName" }; search.Sort = sortOption; DirectoryVirtualListView dvlv = new DirectoryVirtualListView(); dvlv.Target = searchCriteria.Trim(); dvlv.BeforeCount = 0; dvlv.AfterCount = 10; search.VirtualListView = dvlv; SearchResultCollection collection = search.FindAll()
Just wondering if anyone knows what the issue would be?
Also, while 'collection' will contain 10 results, if I then make a call to search.VirtualListView.ApproximateTotal; I get a COM exception as this property is not defined. If I breakpoint on the line, count 10 seconds and then check the value it will contain value (the entire number set of the users in A/D - rather than the 5 users I expect to get back).
This is indicating to me that the search is running asynchronously rather than blocking until it has a valid result set. Is there some way I can force it to wait until the search has completed so it does not throw an exception?
Regards
Andy