I have some code that retreive the users present in different groups in Active directory.
string sADPath = "LDAP://" + tbDomain.Text;
string username = tbUsername.Text;
string password = tbPassword.Text;
DirectorySearcher mySearcher = new DirectorySearcher(directoryEntry);
int MaxResults = Int32.MaxValue - 1;
ComboBoxItem selectItem = (ComboBoxItem)ddlGroups.SelectedItem;
String value = selectItem.Value;
mySearcher.Filter = ("(&(objectCategory=person)(objectClass=User)(memberOf=" + value + "))");
mySearcher.SearchScope = SearchScope.Subtree;
foreach (SearchResult temp in mySearcher.FindAll())
{
}
This code works fine for some groups but not for all.
For example it gets me the values of Domain Admins but not users within Domain Users.
It will also not get my users in the Users folder group?
I get 0 value for Domain users at FindAll().