# ldapsearch: find out what groups a user is member of

## PietdeBoer

Hi guys,

I would like to view the memberships a from a user using ldapsearch.. is this possible?

To be a bit more clear; i've got a user named A which is a member of group B.. can i send a ldap query with user A as input that shows me the user is a member of group B?

I tried a lot of combinations:

ldapsearch -h ldapserver -LLL -x -D cn=admin -wxx "(&(objectClass=groupOfNames)(member=00113261))"

Any idea's?

----------

## g.e.n.t.u.x.

hello Pietdeboer

ldapsearch -x -D cn=admin -h ldapserver (&(objectclass=groupOfNames)(memberOf=xyz) thats what i would do

----------

## SeanHarmer

 *g.e.n.t.u.x. wrote:*   

> hello Pietdeboer
> 
> ldapsearch -x -D cn=admin -h ldapserver (&(objectclass=groupOfNames)(memberOf=xyz) thats what i would do

 

If you have properly setup nss_ldap/pam_ldap then you can simply use getent:

```
getent group | grep A
```

----------

