How do you find out all dynamic LDAP groups a user is part of?

3.2k Views Asked by At

Suppose that a user is part of 2 or more dynamic groups. How do I query for a list of all groups a user is part of? I have already checked answers where people speak of static groups which have a 'member' attribute. I found no answer for dynamic groups.

1

There are 1 best solutions below

12
Terry Gardner On

Dynamic groups are no different from static groups except that dynamic group membership is generated upon request, not stored in the database (on most servers). Therefore, use the same method for getting group membership. This might be using member, memberOf, isMemberOf, or something else entirely, depending on the server.

An example:

ldapsearch --hostname hostname --port port                     \
       --baseDN 'dc=example,dc=com' --bindDN cn=RootDN         \
       --bindPasswordFile 'fileWithPassword' --searchScope sub \
       '(uid=username-youre-looking-for)' isMemberOf

This (refactored for your installation) will return a search result containing the DN of the user, and a list of isMemberOf attribute (each with DN syntax) that will be the DN of the groups of which the user is a member.