很抱歉成为一个超级痛苦的人,这一切都很新:(
在这方面已经有很多帮助,但似乎看不出问题,我试图用所有当前 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]);
}
我已经完成并调试了我所知道的一切,搜索者没有找到任何结果,因此为什么组合框中没有填充任何内容。