Created
August 22, 2016 21:41
-
-
Save volure/7e773792b997561340cd82e35633a205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#usage | |
# ./search.sh "(uid=person)" mail | |
# returns the "mail" value from uid person | |
ldaphost=ldap://server:389 | |
ldapuser=cn=config | |
ldappass=password_hele | |
if [[ -z "$2" ]] | |
then | |
ldapsearch -H $ldaphost -D "$ldapuser" -w "$ldappass" -ZZ "$1" | |
else | |
ldapsearch -H $ldaphost -D "$ldapuser" -w "$ldappass" -ZZ "$1" "$2" | sed -n "/^ /{H;d};/$2:/x;\$g;s/\n *//g;s/$2: //gp" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment