我試圖找到最有效的方式來獲取某些類型的對象的父OU已使用DirectorySearcher
查詢來獲取屬性。這些對象的父母是用戶在Active Directory中(直接或間接)成員的組。從DirectorySearcher獲取子對象屬性的最有效方法導致在Active Directory中使用C#
我想我已經找到了一個很好的遞歸解決方案來獲得這些組,但是一旦我有了我的結果集,我不知道最有效的方式來獲取數據。現在,我正在使用每個結果的路徑來獲取數據,就像我只是獲取單個對象一樣。
我想知道是否有更快的方法來做到這一點,可能是通過添加到我的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);
}
}