Skip to content

Instantly share code, notes, and snippets.

@shollingsworth
Last active April 5, 2022 23:26
Show Gist options
  • Save shollingsworth/76c177c420840af3c097a823280b9e25 to your computer and use it in GitHub Desktop.
Save shollingsworth/76c177c420840af3c097a823280b9e25 to your computer and use it in GitHub Desktop.
LDAP search example
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Filter cheatsheet
# https://gist.github.com/jonlabelle/0f8ec20c2474084325a89bc5362008a7
PASSWORD="password"
BN="dc=acme,dc=com"
DN="CN=Joe Smith,OU=Fabrication,OU=Los Angeles,OU=CA,OU=Users,${BN}"
SERVER=ldaps://ldap.acme.com
SEARCH="(&(objectClass=group)(cn=*AWS*))"
ldapsearch -x \
-o ldif-wrap=no `# do not wrap long lines` \
-L `# ldif format` \
-H ${SERVER} \
-D "${DN}" `# user DN` \
-w "${PASSWORD}" \
-b "${BN}" `# CN Basename` \
${SEARCH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment