Skip to content

Instantly share code, notes, and snippets.

@Miciah
Created September 7, 2016 18:46
Show Gist options
  • Save Miciah/c453518dc41eca35b0d058707bc908b2 to your computer and use it in GitHub Desktop.
Save Miciah/c453518dc41eca35b0d058707bc908b2 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
declare -a uids_ary=( ${1//,/ } )
printf -v uids_list '(uid=%s)' "${uids_ary[@]}"
shift
declare -a criteria=( "(|$uids_list)" )
while [[ "${1-}" = *=* ]]
do
criteria+=( "$1" )
shift
done
ldapsearch -x -h ldap.corp.redhat.com -b 'ou=users,dc=redhat,dc=com' \
"${criteria[*]}" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment