PHP LDAP query to get members of specific security Group

Viewed 9039

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.

2 Answers

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..

Related