Problem with DirectorySearcher.FindAll()

G

Guest

Hi,

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
 
M

Marc Scheuner

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.

Yes, that's the default for the search - if you really have more
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);
DirectorySearcher mySearcher = new DirectorySearcher(directoryEntry1);
mySearcher.Filter = ("(objectClass=user)");

mySearcher.PageSize = 500;

Now, AD will send back ALL matching objects in packets of 500 -
totally transparent to you, for you, nothing changes.

MArc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top