在AD中获取帐户属性 [英] Getting Account Attributes in AD

查看:69
本文介绍了在AD中获取帐户属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用获取广告中用户帐户的组(成员)

System.DirectoryService.DirectorySearcher

How can I get the groups (member of) of a user account in AD using

System.DirectoryService.DirectorySearcher

 

推荐答案

Hi Sheen,

Hi Sheen,

应该可以查询"memberOf"成员.在DiretorySearcher中.所以这样的事情应该起作用:

It should be possible to query the "memberOf" inside the DiretorySearcher. So something like this should work:

DirectoryEntry myOU =新的DirectoryEntry("OU =某物,OU =是,DC = dev,DC = local");
DirectorySearcher srch =新的DirectorySearcher(myOU);
srch.SearchScope = SearchScope.Subtree;
srch.Filter =(&(objectCategory = person)(memberOf = cn = Group,ou = yep,dc = dev,dc = local))";

DirectoryEntry myOU = new DirectoryEntry("OU=something,OU=yep,DC=dev,DC=local");
DirectorySearcher srch = new DirectorySearcher(myOU);
srch.SearchScope = SearchScope.Subtree;
srch.Filter = "(&(objectCategory=person)(memberOf=cn=Group,ou=yep,dc=dev,dc=local))";

但是请注意,默认情况下已经存在一个primaryGroupId,即域用户.但是,如果更改了此设置,则如果我的信息正确,您可能会错过一个组.因此,如果您也想解决这个问题,则应该获取 分组并将搜索更改为以下内容:

But be aware, that there is already a primaryGroupId which is the domain users by default. But if that is changed, you might miss a group if my information is correct. So if you want to take care of that, too, you should get the primaryGroupToken of the group and change the search to something like:

"((&(objectCategory = person)(|(memberOf ="& groupDN&" ")(primaryGroupID =& groupRID&" )))"

"(&(objectCategory=person)(|(memberOf=" & groupDN & ")(primaryGroupID=" & groupRID & ")))"

以诚挚的问候,

Konrad


这篇关于在AD中获取帐户属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆