Using curl for querying Active Directory / LDAP from command line

For quering Active Directory /LDAP from command line, you can run something like curl -u DOMAIN\\\\MYACCOUNT:MYPASSWORD \\ "ldap://dc.redaelli.org:3268/OU=users,DC=redaelli,DC=org?memberOf,sAMAccountName?sub?(sAMAccountName=matteo)" Comments: Saqib Ali - Dec 1, 2018Super thanks for posting this!

May 18, 2012 · 1 min · 29 words · Matteo Redaelli

Howto quickly extract LDAP attributes for a list of users

I had a list of email addresses and my boss asked me to extract the login names (SamAccountname attribute in Active Directory). I quickly did it with: cat mails.txt | while read mail do echo /usr/bin/curl -s --proxy \"\" -u \"MYDOMAIN\\myuser:mypassword\" \"ldap://ldapserver:3268/DC=group,DC=mycompany,DC=com?sAMAccountName?sub?(mail=${mail})\" done | bash | grep "sAMAccountName:" | cut -f2 -d":" | sed -e 's/^ /"/' -e 's/$/",/'

1 min · 59 words · Matteo Redaelli