I am new to LDAP and learning about the ldapsearch and ldap in general. Would like to write a shell script that enumerate the (already existing) LDAP group "VPN Users", then get all user "samaccountname" (e.g.joe.smith). Can someone please help? I've tried to do it but seems like my ldapsearch has errors:
ldapsearch -h 127.0.0.1 -x -b (&(objectCategory=group)(cn=VPN Users))
Edit - Sorry about that. I made some progress and now at least cat get some data from the LDAP server by running something like this:
echo -n 'password' |
ldapsearch -y pass.txt -h [IP here] -b "ou=x,dc=x,dc=x,dc=x" -x `
-D "cn=user,ou=test,ou=x,ou=x,dc=x,dc=x,dc=xx" `
-W "(&(objectClass=person)(objectClass=user)(sAMAccountName=*) (memberOf=cn=VPN Users,ou=test,ou=x,ou=x,dc=x,dc=x,dc=xx))" `
-y /dev/fd/0
But I would like it to:
- enumerate the (already existing) LDAP group "VPN Users"
- get all user "samaccountname" (e.g. joe.smith, etc.)
Thanks