5

很抱歉成为一个超级痛苦的人,这一切都很新:(

在这方面已经有很多帮助,但似乎看不出问题,我试图用所有当前 OU 的列表填充一个组合框,稍后向该 OU 中的每台机器发送关闭命令。(Acquiring AD OU list & Active Directory list OU's)是我之前的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]);
        }

我已经完成并调试了我所知道的一切,搜索者没有找到任何结果,因此为什么组合框中没有填充任何内容。

4

2 回答 2

3

我不得不使用非索引 objectClass 而不是 Catergory。

您只需要正确拼写即可:objectCategory - not objectCate r gory

(你的“r”太多了...... :-)

于 2010-05-27T14:40:57.693 回答
2

作品:) :)

我不得不使用非索引 objectClass 而不是 Catergory。

组合框现在填充得很好。

编辑:{“(objectClass=organizationalUnit)”}

于 2010-05-27T11:15:05.823 回答