Skip to content

Instantly share code, notes, and snippets.

@calum-github
Last active November 29, 2016 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calum-github/e622e66254452918521d3ad391fb690a to your computer and use it in GitHub Desktop.
Save calum-github/e622e66254452918521d3ad391fb690a to your computer and use it in GitHub Desktop.
Ldap search query
#!/bin/bash
## Start by loading up our ldap query variables
SVC_ACCOUNT_NAME="Username"
SVC_ACCOUNT_PASS="Password"
DOMAIN="my.domain"
LDAP_SERVER="dc.my.domain:389"
SEARCH_BASE="OU=Users,DC=My,DC=Domain"
ldapsearch -LLL -H ldap://$LDAP_SERVER -E pr=1000/noprompt -o ldif-wrap=no -x -D ${SVC_ACCOUNT_NAME}@$DOMAIN -w ${SVC_ACCOUNT_PASS} -b "${SEARCH_BASE}" \
-s sub -a always "(objectClass=user)" "sAMAccountName" "objectGUID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment