Skip to content

Instantly share code, notes, and snippets.

@mwicat
Created September 28, 2011 09:42
Show Gist options
  • Select an option

  • Save mwicat/1247501 to your computer and use it in GitHub Desktop.

Select an option

Save mwicat/1247501 to your computer and use it in GitHub Desktop.
ldap user search
#!/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