Skip to content

Instantly share code, notes, and snippets.

@stefanschmidt
Last active June 5, 2024 07:17
Show Gist options
  • Save stefanschmidt/ce0de4844bd573aede664b1bff167412 to your computer and use it in GitHub Desktop.
Save stefanschmidt/ce0de4844bd573aede664b1bff167412 to your computer and use it in GitHub Desktop.
Authenticate via LDAP on the command line
# Using an LDAP test server we will authenticate the user newton
# http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
# method 1: using ldapwhoami
# should return "Result: Success (0)" if authentication was successful
ldapwhoami -vvv -h ldap.forumsys.com -D "uid=newton,dc=example,dc=com" -x -w password
# method 2: using ldapsearch
# should return "result: 0 Success" if authentication was successful
ldapsearch -h ldap.forumsys.com -x -D uid=newton,dc=example,dc=com -w password -b "dc=example,dc=com" "(uid=newton)"
# Using a local LDAP server we will authenticate the user admin
# Tools will prompt for the password specified during installation of OpenLDAP
# https://www.unixmen.com/install-openldap-in-ubuntu-15-10-and-debian-8/
# method 1: using ldapwhoami
# should return "Result: Success (0)" if authentication was successful
ldapwhoami -vvv -h localhost -D "cn=admin,dc=test,dc=netz" -x -W
# method 2: using ldapsearch
# should return "result: 0 Success" if authentication was successful
ldapsearch -h localhost -x -D "cn=admin,dc=test,dc=netz" -W -b "dc=test,dc=netz" "(cn=admin)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment