LDAP get user email

email, ldap

Solution

`ldapsearch -h Hostname -p port# -D dc=prefix1,dc=db -b cn=username,cn=User,dc=prefix1,dc=db "sAMAccountName=YourUsersName" mail`

You will need the real DN of the Acount name, which you can search for, using same as above, and get the DN out of the result.

Problem

LDAP How can I get user email attribute from LDAP server for domain user using bash? I suppose that I should use ldapsearch command. I have the following information about ldap server: Server Name: server.url Server Port number: portnum Search base: dc=prefix1,dc=db Account name: domain\user_name Password: domain_password

Original source