代码中设置一下 PageSize 即可,
参考代码:
//得到Ad中所有用户
public static SearchResultCollection GetAllUsers(string adPath, string adMIN, string adPWD)
{
try
{
DirectoryEntry entry = new DirectoryEntry(adPath, adMIN, adPWD, DefaultAuthenticationType);
// DirectoryEntry entry = new DirectoryEntry(ADPath, ADMIN, AdPWD, DefaultAuthenticationType);
DirectorySearcher directorySearch = new DirectorySearcher(entry);
// LDAP://sensen.com/CN=001216,OU=User,OU=JR,DC=sensen,DC=com
directorySearch.Filter = "(&(objectClass=user))";
// directorySearch.Filter = "(&(objectClass=organizationalUnit)(ou=JR))";
directorySearch.Sort.PropertyName = "cn";
directorySearch.SearchScope = SearchScope.Subtree;
directorySearch.PageSize = 5000;
SearchResultCollection results = directorySearch.FindAll();
if (results != null)
{
return results;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
这个问题在微软的网站已经给出了解决方案 :http://support.microsoft.com/kb/315071