【发布时间】:2010-05-26 10:13:43
【问题描述】:
很抱歉成为一个超级痛苦的人,这一切都是新的:(
已经在这方面得到了很多帮助,但似乎无法看到问题所在,我正在尝试用所有当前 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]);
}
我已经通过并调试了我所知道的一切,搜索器没有找到任何结果,因此为什么组合框中没有填充任何内容。
【问题讨论】:
-
我刚刚尝试手动添加整个 LDAP 路径 entryToQuery = "LDAP://OU=G-T-P,DC=G-T-P,DC=LOCAL" 我知道这里肯定有部门 OU树,我已经替换了要加载到 ["distinguishedName"] 的属性,以查看它是否可以将其拉回来,尽管考虑它不会有任何区别。在这一点上超级难倒!!!
-
+1 关于广告相关问题的有趣问题。
标签: c# active-directory ldap directoryservices