This is due to a server-side limit. From the DirectorySearcher.SizeLimit
documentation:
The maximum number of objects that the
server returns in a search. The
default value is zero, which means to
use the server-determined default size
limit of 1000 entries.
And:
If you set SizeLimit to a value that is larger than the server-determined default of 1000
entries, the server-determined default is used.
Basically from this, it looks like unless there's a way of changing the server-side default, you're going to be limited to 1000 entries. It's possible that specifying a PageSize
will let you fetch a certain number at a time, with a total greater than 1000... not sure.
By the way, it looks like you should also have a using
directive around the SearchResultCollection
:
using (SearchResultCollection results = ds.FindAll())
{
foreach (SearchResult sr in results)
{
...
}
}