Searching Active Directory
I trying to write an application that search for a given user in active directory and the groups that the given user is part of. The problem is that the user is under a organizational units (folder) and I am not able get to the information.
Bellow is the code that I am using. Can any one help me? Thank you
DirectoryEntry entry = new DirectoryEntry("LDAP://hq-2k3/cn=rtest,cn=IT,DC=kaneCompany,DC=com");
PropertyValueCollection col = entry.Properties["MemberOf"];
IEnumerator enumerator = col.GetEnumerator();
Console.WriteLine("Groups are " + enumerator.Current.ToString());
//if this gives error then u might need to type case it to AD group object.