I am trying to retrieve 5000 users from AD group, but when I set PageSize= 1000 (or let's say 15000) and SizeLimit=15000 , I still get only 1500 users. Any other configuration that I can set (I want to avoid range retrieval as suggested by MS) Please advice. Thanks Below is the code section: Please let me know what am I missing.
retrieving 1000+ users from AD group using C#
Collapse
X
-
Code:private SearchResultCollection ExecuteBestEffortSearch(DirectorySearcher searcher) { if (searcher == null) { throw new ArgumentNullException("searcher"); } if (searcher.SearchRoot == null) { throw new ArgumentException("Directory Searcher does not have a search root.", "searcher"); } // Construct Search Message string message = String.Format("[{0}] ({1}) with filter [{2}] for attributes [{3}]", searcher.SearchRoot.Path, searcher.SearchScope, searcher.Filter, FlattenStringCollection(searcher.PropertiesToLoad)); // Execute Search try { if (Logger.DebugLevel >= Logger.MaxDebugLevel) { Logger.Debug(0, "Executing directory search for " + message, null, DirectoryServiceException.ModuleName, Logger.MaxDebugLevel); } searcher.PageSize = 1000; //a positive number to turn off the default page limit in DirectorySearcher return searcher.FindAll(); } catch (COMException adsiException) { DirectoryServiceException dsExeception = DirectoryServiceException.Create( String.Format("The directory search {0} was unable to execute due to a directory service error.", message), adsiException); if (dsExeception is DirectoryServerUnavailableException) { try { Guid searchRootGuid = searcher.SearchRoot.Guid; // Cleanup resources searcher.SearchRoot.Dispose(); // Attempt to Re-Bind using (DirectoryEntry searchRootEntry = GetEntryByGuid(searchRootGuid)) { searcher.PageSize = 1000; //a positive number to turn off the default page limit in DirectorySearcher searcher.SearchRoot = searchRootEntry; return searcher.FindAll(); } } catch (Exception ex) { Logger.LogError(30019, String.Format("The directory search {0} failed because the search root was unavailable and the server was not able to establish a new bind.", message), ex, DirectoryServiceException.ModuleName, Logger.MinDebugLevel); } } throw dsExeception; } }Last edited by Rabbit; Jan 7 '16, 10:50 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.Comment
Comment