【发布时间】:2017-11-17 21:36:55
【问题描述】:
我试图找到最有效的方法来从某些类型的对象中获取属性,这些对象的父 OU 已使用 DirectorySearcher 查询进行了聚合。这些对象的父对象是用户在 Active Directory 中(直接或间接)所属的组。
我想我已经找到了一个很好的递归解决方案来获取这些组,但是一旦我有了我的结果集,我不确定获取数据的最有效方法是什么。现在我正在使用每个结果的路径来获取数据,就像我只是获取一个对象一样。
我想知道是否有更快的方法来做到这一点,可能通过添加到我的DirectorySeacher 的Filter 并直接在我的查询结果中获取这些对象。我正在搜索的对象是对象,因此在 DirectorySearcher 查询中我能找到的最接近它们的对象将是它们的父 OU。
foreach (SearchResult result in matchingADGroups)
{
// Here I need to get result's child object properties(could be multiple children)
DirectoryEntry entry = new DirectoryEntry("LDAP://" + result.Path.Substring(7));
foreach(DirectoryEntry child in entry.Children)
{
Shortcut shortcut = new Shortcut();
shortcut.DisplayName = (string)child.Properties["myDisplayName"].Value;
shortcut.Id = (string)child.Properties["myId"].Value;
shortcuts.Add(shortcut);
}
}
【问题讨论】:
标签: c# active-directory directory ldap