The code below works just fine, however what's happening is the code limits the results to 1500 users and we have more than 1500 users. What I'm trying to do is retrieve a list of all users that are a member of a specific group. I know DirectorySearcher
has a PageSize setting however, I'm unable to find a way to set DirectoryEntry PageSize will still only pulling members of that group.
Does anybody know a way to change the page size? Or maybe how to pull members of a specific group in another fashion that will accommodate pagesize?
DirectoryEntry dEntryhighlevel = new DirectoryEntry("LDAP://CN=Users,OU=MyOu,OU=Clients,OU=Home,DC=bridgeTech,DC=net");
foreach (object dn in dEntryhighlevel.Properties["member"])
{
DirectoryEntry singleEntry = new DirectoryEntry("LDAP://" + dn);
DirectorySearcher dSearcher = new DirectorySearcher(singleEntry);
//filter just user objects
dSearcher.SearchScope = SearchScope.Base;
//dSearcher.Filter = "(&(objectClass=user)(dn=" + dn + "))";
//dSearcher.PageSize = 1000;
SearchResult singleResult = null;
singleResult = dSearcher.FindOne();
if (singleResult != null)
{
string Last_Name = singleResult.Properties["sn"][0].ToString();
string First_Name = singleResult.Properties["givenname"][0].ToString();
string userName = singleResult.Properties["samAccountName"][0].ToString();
string Email_Address = singleResult.Properties["mail"][0].ToString();
OriginalList.Add(Last_Name + "|" + First_Name + "|" + userName + "|" + Email_Address);
}
singleEntry.Close();
}