LDAP Queries

sudo apt-get install libnss-ldap ldap-utils
To get the attribute 'memberOf'

# Simple Bind with TLS
ldapsearch -v -x -Z -D "user@domain.loca" -W -H ldap://ad.domain.local -b  'OU=People,DC=domain,DC=local' '(sAMAccountName=someuser)' memberOf

# older style
ldapsearch -v -D "user@domain.local" -w Passw0rd -H ldap://ad1.domain.local -b 'OU=People,DC=domain,DC=local' '(sAMAccountName=someuser)' memberOf

# Get all user accounts from AD created since 2007-07.

 ldapsearch -v -x -Z -D "user@domain.local" -W -H ldap://ad1.domain.local -b 'DC=domain,DC=local' -E pr=1000/noprompt '(&(objectClass=user)(whenCreated>=20100701000000.0Z))' sAMAccountName description whenCreated > all


Comments