I have a code to get the list of OUs within a domain.
Now this just lists all the OUs and does not give any way to distinguish between an OU and a sub OU.
DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=organizationalUnit)");
foreach (SearchResult temp in mySearcher.FindAll())
{
OU_DownList.Items.Add(temp.Properties["name"][0].ToString());
}
Is there a way i can get the fully qualified name of an OU?
Something like this for a sub OU:
CN=Computer1,OU=Department 101,OU=Business Unit #1,DC=us,DC=xyz,DC=com
Any help is appreciated... thanks
temp.Path
should get you the distinguishedName of each OU.