DirectorySearcher および Filter/PropertiesToLoad を使用して、特定のグループ/部門内のすべてのメンバーおよび (のメンバー)サブグループのリストを取得するにはどうすればよいですか?
現時点では、グループにすべてのメンバーを戻すことができます。ただし、グループ内にサブグループがあり、それらのサブグループ内のメンバーにもアクセスできません。
これは私がこれまでに持っているものです:
DirectoryEntry entry = null;
entry = new DirectoryEntry("LDAP://DC=au,DC=company,DC=com", null, null, AuthenticationTypes.Secure);
try
{
DirectorySearcher ouSearch = new DirectorySearcher(entry);
ouSearch.Filter = "(&(objectClass=user)(objectCategory=person)(displayName=*" + username + "*)" +
"(|" +
"(memberOf=CN=my department,OU=ADC-Distribution Groups,DC=au,DC=company,DC=com)" +
")" +
")";
ouSearch.PropertiesToLoad.Add("samAccountName");
ouSearch.PropertiesToLoad.Add("displayName");
ouSearch.PropertiesToLoad.Add("memberOf");
ouSearch.SearchScope = SearchScope.Subtree;
SearchResultCollection allOUS = ouSearch.FindAll();
どんな支援も大歓迎です!