I have what I think is a simple project, but I am having trouble digesting tutorials on the web so I was hoping somebody could clarify. I have been looking at ldap and ldapsearch commands.
My company has an LDAP directory which I would like to query to pull information such as name, dept #, phone number etc. The search string that I have to work with is an email address.
Can somebody provide some insight, or point me in the direction on how I can get this done in a BASH script?
You will need to browse AD and find the correct OU and DC plus the fields you are interested most organisations will populate OU and different fields so this is usually the biggest hurdle
Here is an example of searching for mail address and displaying some info:
MAIL="auser@acme.com"
ldapsearch -h mydchost.acme.local -b 'OU=Acme Group,DC=acme,DC=local' -D 'ACME\sudo' -W "(&(objectclass=*)(mail=$MAIL))" cn mail department phone
You can try running without specifying any fields and try an pick out what you are interested in:
Try downloading the application called GetMyDN.exe in domain to get your own Distinguished Name. Then the last part before the "User Accounts" or such is you value you want to start your ldapsearch at.