Last post Apr 25, 2014 08:16 AM by smirnov
Apr 07, 2014 09:51 PM|srenu|LINK
I need to find whether a OrganisationUnit has node Users. Below is a sample of ActiveDirectory.
For example OU=AHSC is having sub node OU=Users Then i want to copy the Object Name of OU=Users which is something like this - OU=Users,OU=AHSC,DC=sf,DC=sp,DC=edu,DC=sg
I want all OU which has subnodes OU=Users
I tried to achieve with DirectorySearcher, i am able to read entire data in AD but i want only OU with subnode OU=Users.
Apr 25, 2014 08:16 AM|smirnov|LINK
string ldapPath = "LDAP://corp.net:389/dc=corp,dc=net";
DirectoryEntry de = new DirectoryEntry(ldapPath);
DirectorySearcher s = new DirectorySearcher(de);
s.SearchScope = SearchScope.Subtree;
s.Filter = "(OU=Users)";
SearchResultCollection results = s.FindAll();
foreach (SearchResult searchResult in results)
Label1.Text += searchResult.Properties["distinguishedName"] + ";";