如何使用 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();
任何帮助表示赞赏!