DirectoryEntry rootEntry = new DirectoryEntry("LDAP://<AD_SERVER>/dc=DOMAIN,dc=COM");
DirectorySearcher dsFindOUs = new DirectorySearcher(rootEntry);
dsFindOUs.Filter = "(objectClass=organizationalUnit)";
dsFindOUs.SearchScope = SearchScope.Subtree;
foreach (SearchResult result in dsFindOUs.FindAll())
{
Console.WriteLine(result.Path);
}
|