0

My question is very similar to how to get groups of a user in ldap but I want to be able to search a group whose member has attribute foo with value bar

ie, from the previous question instead of doing (&(objectClass=groupOfNames)(member=cn=root,ou=django,dc=openldap))

I want to do something like (&(objectClass=groupOfNames)(member=sn=bar)) but it seems only the full DN can be used for such query. Is there another way to find groups for user matching a pattern?

Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84

1 Answers1

0

Since memberOf is available to you, you can search for the users instead of the groups:

(&(objectClass=person)(sn=bar))

(You might have to change the objectClass depending on what it is for users. I'm used to Active Directory, not OpenLDAP.)

Then you can read the memberOf attribute of the users you find.

Update: If you just want to find members of that group with that attribute then you can do it in one query by using memberOf in the query, and looking for the DN of the group:

(&(objectClass=person)(sn=bar)(memberOf=CN=MyGroup,DC=whatever))
Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84