User Tools

Site Tools


linux:scripts:ldap

LDAP

Tried to get some mail adresses. Might be helpful for someone

#!/bin/bash


USERNAME=$1

#get a mailaddress by "SN -> surname", cut away "mail:" 
ldapsearch -LLL -x -D "lunetikk@lunetikk.de" -w "<PASSWORD>" -b "OU=Standard Benutzer,OU=Benutzer,OU=Benutzer und Gruppen,OU=Organisation,DC=lunetikk,DC=de" -H "ldap://mydomaincontroller.lunetikk.de" "SN=$USERNAME" mail | sed -n 's/^[ \t]*mail:[ \t]*\(.*\)/\1/p'

#get a mailaddress by "CN -> commonname", cut away "mail:" 
ldapsearch -LLL -x -D "lunetikk@lunetikk.de" -w "<PASSWORD>" -b "OU=Lunetikk,OU=Verteilergruppen,OU=Ressourcen,OU=Organisation,DC=lunetikk,DC=de" -H "ldap://mydomaincontroller.lunetikk.de" "CN=$USERNAME" mail | sed -n 's/^[ \t]*mail:[ \t]*\(.*\)/\1/p'

#get a displayname and info by "CN" 
ldapsearch -LLL -x -D "lunetikk@lunetikk.de" -w "<PASSWORD>" -b "OU=Lunetikk,OU=Verteilergruppen,OU=Ressourcen,OU=Organisation,DC=lunetikk,DC=de" -H "ldap://mydomaincontroller.lunetikk.de" "CN=$USERNAME" displayName info

#get all attributes (?) by "CN" 
ldapsearch -LLL -x -D "lunetikk@lunetikk.de" -w "<PASSWORD>" -b "OU=Lunetikk,OU=Verteilergruppen,OU=Ressourcen,OU=Organisation,DC=lunetikk,DC=de" -H "ldap://mydomaincontroller.lunetikk.de" "CN=$USERNAME" \* +
echo " "
echo " "

ldapsearch -LLL -x -D "lunetikk@lunetikk.de" -w "<PASSWORD>" -b "OU=Lunetikk,OU=Verteilergruppen,OU=Ressourcen,OU=Organisation,DC=lunetikk,DC=de" -H "ldap://mydomaincontroller.lunetikk.de" '(memberof=cn=lunetikk,dc=lunetikk,dc=de)'
linux/scripts/ldap.txt · Last modified: 2017/12/19 09:45 (external edit)