LDAP query for OU

Sorry for being sick with people, all this is very new :(

We already had a lot of help, but it seems that I do not see a problem, I am trying to fill out a list box with all the current units, and then send each machine within this unit. off. (Acquiring AD OU and OU in Active Directory) were my previous Q.

        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 went through and debug everything that I know, the search engine does not collect any results, so why is nothing populated in the list box.

+5
source share
2 answers

I had to use not indexed objectClass, not Catergory.

: objectCategory - objectCate r gory

( "r".....: -)

+3

:):)

objectClass, Catergory.

.

EDIT: { "( = OrganizationalUnit)" }

+2

All Articles