phpactive-directoryldap

PHP LDAP query to get members of specific security Group


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.


Solution

  • 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