Search code examples
phpactive-directoryldap

How to get all groups a users is member of in Active Directory, in PHP (connecting to LDAP directory)


I have a website which can check if a user is member a of a specific group in Active Directory. Now I want to echo all groups which a user is a member of. I can't find any examples of this in the internet, and I don't know where to start. Any help is appreciated. Please take in mind that I'm not a professional programmer/webdesigner.

I'm checking on the users sAMAccountname. Thanks in advance.


Solution

  • You need to check memberOf multivalued attribute.

    It contains full DN of group.

    This question has already been answered here: PHP LDAP Get user details of member which is a member of a group