Created
September 28, 2011 09:42
-
-
Save mwicat/1247501 to your computer and use it in GitHub Desktop.
ldap user search
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 | |
| read -sp "Password: " passw < /dev/tty | |
| host=$1 | |
| user=$2 | |
| base=$3 | |
| query=$4 | |
| function adsearch { | |
| query=$1 | |
| ldapsearch -x -LLL -D "$user" -b "$base" -w "$passw" -h "$host"($query)" samaccountname | |
| } | |
| function getusername { | |
| perl -nle '/sAMAccountName: (.*)/ && print $1' | |
| } | |
| adsearch "$passw" "$query" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment