Created
October 22, 2020 22:07
-
-
Save talkingmoose/92a29520de5235214295a4bca377fb63 to your computer and use it in GitHub Desktop.
Syntax for looking up user information from a non-bound LDAP directory.
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/sh | |
# -H = LDAP URI | |
# -x = use simple authentication instead of SASL | |
# -b = search base | |
# -D = user principal name (UPN) of authenticating user | |
# -w = password of authenticating user | |
# look up a user's manager's distinguished name | |
/usr/bin/ldapsearch -H ldap://192.168.5.250:389 -x -b 'cn=users,dc=talkingmoose,dc=pvt' -D '[email protected]' -w 'P@55w0rd' cn="Martin Moose" manager | /usr/bin/grep 'manager:' | /usr/bin/awk -F ": " '{ print $2 }' | |
<<RESULTS | |
----------------------------------------------------------------- | |
CN=Clark Griswold,CN=Users,DC=talkingmoose,DC=pvt | |
----------------------------------------------------------------- | |
RESULTS | |
# look up manager's email address | |
/usr/bin/ldapsearch -H ldap://192.168.5.250:389 -x -b 'cn=users,dc=talkingmoose,dc=pvt' -D '[email protected]' -w 'P@55w0rd' distinguishedName='CN=Clark Griswold,CN=Users,DC=talkingmoose,DC=pvt' mail | /usr/bin/grep 'mail:' | /usr/bin/awk '{ print $2 }' | |
<<RESULTS | |
----------------------------------------------------------------- | |
[email protected] | |
----------------------------------------------------------------- | |
RESULTS | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment