Get 2000 of 6000 records from DirectorySearcher

user175084 picture user175084 · Jun 1, 2012 · Viewed 8.6k times · Source

I have a code which either gets 1000 or all the results using DirectorySearcher.

But I want to get only 2000 of 6000 results.

Here is the code to get 6000 results whereas I only want 2000

mySearcher.SizeLimit = 2000;
mySearcher.PageSize = 1000;

SearchResultCollection results = mySearcher.FindAll();

int totalUsers = results.Count;

Please help.

Thanks

My research says PageSize = 0 gives 1000 results only and Pagesize = 1000 gives all results.

Need more help to make this work.

Answer

Magnus Johansson picture Magnus Johansson · Jun 1, 2012

There seems to be a slight weird behavior with the PageSize property.
Please set it to 0 , does that work?

By the way:
c# Active Directory Services findAll() returns only 1000 entries

Can I get more than 1000 records from a DirectorySearcher in Asp.Net?