Search code examples
ldap-query

Return email only from LDAP query


Let's say I have a query like:

(objectCategory=user) (memberOf=CN=Clients,OU=Mybusiness,DC=mydomain.local,DC=com)

Is there a way to request that only the email of the users AD record be returned?

Thank you!


Solution

  • Just define 'mail' as the return attribute of the query.

    E.g. using ldapsearch

    ldapsearch -h HOST -p PORT -D 'Bind-DN' ..... -b SEARCHBASE "(&(memberOf=CN=Clients,OU=Mybusiness,DC=mydomain.local,DC=com)(objectcategory=user))" mail