Sorry for being an uber pain people, its all very new :(
Already had alot of help on this, but don't seem to be able to see the problem, I am trying to populate a combo box with a list of all the current OU's, later to send each machine within that OU a shutdown command. (Acquiring AD OU list & Active Directory list OU's) were my previous Q's.
string defaultNamingContext;
//TODO 0 - Acquire and display the available OU's
DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
defaultNamingContext = rootDSE.Properties["defaultNamingContext"].Value.ToString();
DirectoryEntry entryToQuery = new DirectoryEntry ("LDAP://" + defaultNamingContext);
MessageBox.Show(entryToQuery.Path.ToString());
DirectorySearcher ouSearch = new DirectorySearcher(entryToQuery.Path);
ouSearch.Filter = "(objectCatergory=organizationalUnit)";
ouSearch.SearchScope = SearchScope.Subtree;
ouSearch.PropertiesToLoad.Add("name");
SearchResultCollection allOUS = ouSearch.FindAll();
foreach (SearchResult oneResult in allOUS)
{
//comboBox1.Items.Add(oneResult.ToString());
comboBox1.Items.Add(oneResult.Properties["name"][0]);
}
I have been through and debugged everything i know, the searcher isn't picking up any results, hence why nothing is populated in the combo box.
LDAP - Organizational unit (OU)The organizational unit attribute refers to the organizational unit (or sometimes the user group) that the user is part of. If the user is part of more than one group, you may specify as such, e.g., OU= Lawyer,OU= Judge.
dc. Domain Component. The AdsPath of an object in Active Directory (the binding string) consists of the provider moniker (LDAP://) appended to the Distinguished Name of the object. The Distinguished Name specifies not just the name of the object, but also its location in the Active Directory hierarchy.
DC objects represent the top of an LDAP tree that uses DNS to define its namespace. Active Directory is an example of such an LDAP tree. The designator for an Active Directory domain with the DNS name Company.com would be dc=Company,dc=com. Organizational Unit (OU). OU objects act as containers that hold other objects.
I have had to use the non indexed objectClass rather than Catergory.
You just need to spell it correctly: objectCategory - not objectCatergory
(you have an "r" too much in there..... :-)
Works :) :)
I have had to use the non indexed objectClass rather than Catergory.
The combo box has populated perfectly fine now.
EDIT: { "(objectClass=organizationalUnit)" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With