Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2006

Tip: Looking for answers? Try searching our database.

Problem with DirectorySearcher.FindAll()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
barbutz - 06 Jun 2006 14:15 GMT
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
Marc Scheuner - 07 Jun 2006 05:53 GMT
>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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.