PHP LDAP query to get members of specific security Group

浪尽此生 提交于 2019-12-23 18:27:55

问题


I am struggling to get an LDAP query to work to give me members of a security Group.

Our active directory structure is set up with

DC=domain,DC=co,dc=uk We then have a OU called Company users and within that an OU for IT,and Standard.

Within these we have the users created

So I am set up as CN=my name,OU=IT,OU=company users,DC=domain,DC=co,dc=uk

The security Group is CN=Test,OU=Security Group,DC=domain,DC=co,dc=uk

Of which I am a member of .

I have a PHP page that runs an LDAP query that is set to have a DN of OU=Company users,DC=domain,DC=co,dc=uk with a filter of (&(objectClass=user)(objectCategory=person)) and this returns all users and works fine.

I can not however get it to return just members of my Test group even though I seem to have tried every query Google has given me.

I think it is due to how we have the structure set up.

Can anyone help.


回答1:


you can do this:

(&(objectClass=user)(objectCategory=person)(memberof=CN=Test,OU=Security Group,DC=domain,DC=co,dc=uk))

in your filter, this will then bring out the correct users. If this is incorrect you might want to check out the ADSI Edit program on the Domain controller, this will give you the correct DN.

I hope this helps, good luck




回答2:


Here is what ive done:

$dn = "CN=Users,DC=domain,DC=co,dc=uk";
$result = @ldap_search($ldap, $dn, "memberof=CN=MySecGroup,{$dn}", ["description", "displayname"]);

and it worked..



来源:https://stackoverflow.com/questions/20495191/php-ldap-query-to-get-members-of-specific-security-group

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!