Created
February 1, 2012 21:37
-
-
Save scottsbaldwin/1719621 to your computer and use it in GitHub Desktop.
active directory search
This file contains 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 | |
if [ "$1" == "" ] | |
then | |
echo "USAGE: $0 [search_term]" | |
exit | |
fi | |
HOST=foo.bar | |
ADMIN_USERNAME=DOMAIN\user | |
ADMIN_PASSWORD=mypass | |
# change the ou to match your active directory (and the dc parts) | |
BASE_DN="ou=Corp,dc=foo,dc=bar" | |
SEARCH_TERM=$1 | |
ldapsearch -x -LLL -h ${HOST} -D ${ADMIN_USERNAME} -w ${ADMIN_PASSWORD} -b ${BASE_DN} -s sub "(sAMAccountName=${SEARCH_TERM})" cn mail sAMAccountName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment