System.DirectoryServices.AccountManagement PageSize limit 1000

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im using PrincipalContext, UserPrincipal and PrincipalSearcher to get the total number of objects in a particular OU. I know total is somewhere around 9,000. But what I get is 1,000. Ive tried modifying the underlying searcher to set
PageSize and SizeLimit, but same result. Here is the code:
<pre lang="x-cpp public int TotalEnabledUsers
{
get
{
UserPrincipal user_principal = new UserPrincipal(principal_context);
user_principal.Enabled = true;

PrincipalSearcher principal_searcher = new PrincipalSearcher(user_principal);
principal_searcher.QueryFilter = user_principal;

(principal_searcher.GetUnderlyingSearcher() as DirectorySearcher).PageSize = max_page_size;
(principal_searcher.GetUnderlyingSearcher() as DirectorySearcher).SizeLimit = max_result_size;

int count = principal_searcher.FindAll().Count();

Console.WriteLine("Count:" + count);

return count;
}
}

[/code]

View the full article
 
Back
Top