|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with DirectorySearcher.FindAll()I have a method which retrieves all users from Active Directory 2000. The problem is that i don't get all the users but only 1000 users. I've changed the search query limit from the AD itself to 20000 - via the Group Policy and verified also in the registry as instructed from this site http://www.petri.co.il/active_directory_search_limit.htm. But still that didn't help, i still get 1000 users in my search query (i've also restarted the AD machine). My code is as follows: DirectoryEntry directoryEntry1=new DirectoryEntry(RootDSE,name,psw); DirectorySearcher mySearcher = new DirectorySearcher(directoryEntry1); mySearcher.Filter = ("(objectClass=user)"); mySearcher.SizeLimit = 20000; <-- Omitting this line doesn't help also SearchResultCollection results = mySearcher.FindAll(); Console.WriteLine("Retrieved: " + results.Count.ToString()); <-- I get only 1000, there are a lot more Thanks for your help >I have a method which retrieves all users from Active Directory 2000. Yes, that's the default for the search - if you really have more>The problem is that i don't get all the users but only 1000 users. objects and need them all, you'll need to do "paged" searches by setting the .PageSize property on the DirectorySearcher: >DirectoryEntry directoryEntry1=new DirectoryEntry(RootDSE,name,psw); mySearcher.PageSize = 500;>DirectorySearcher mySearcher = new DirectorySearcher(directoryEntry1); >mySearcher.Filter = ("(objectClass=user)"); Now, AD will send back ALL matching objects in packets of 500 - totally transparent to you, for you, nothing changes. MArc |
|||||||||||||||||||||||