LDAP WhoAmI Tool
Discover how to use the LDAP WhoAmI tool to identify users and manage directory access effectively in LDAP environments.
Table of Contents
ldapwhoami is an OpenLDAP command-line utility used to determine the identity that the LDAP server sees after authentication.
It is commonly used to:
- verify authentication credentials
- test LDAP bind operations
- confirm SASL identity mappings
- troubleshoot authentication issues
The command performs a Who Am I? extended operation against the LDAP server and returns the authorization identity.
Basic Syntax
ldapwhoami [options]ldapwhoami -x -H ldap://ldap.example.com -D "cn=admin,dc=example,dc=com" -W| Option | Meaning |
|---|---|
-x |
Use simple authentication |
-H |
LDAP server URI |
-D |
Bind DN |
-W |
Prompt for password |
Example Using LDAP
This example authenticates using a standard LDAP connection.
ldapwhoami -x -H ldap://ldap.example.com -D "uid=jdoe,ou=people,dc=example,dc=com" -Wdn:uid=jdoe,ou=people,dc=example,dc=comExample Using LDAPS (Secure LDAP)
If your LDAP server requires TLS encryption, use
ldaps.ldapstypically uses port 636
ldapwhoami -x -H ldaps://ldap.example.com -D "uid=jdoe,ou=people,dc=example,dc=com" -WUsing SASL EXTERNAL with LDAPI
Administrators often use ldapwhoami to verify local administrative access using the ldapi socket and SASL EXTERNAL authentication.
ldapwhoami -Y EXTERNAL -H ldapi:///dn:gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=authTesting Authentication Without a Bind DN
ldapwhoami can also test anonymous authentication.
ldapwhoami -x -H ldap://ldap.example.comanonymousIf anonymous binds are disabled, you may see:
ldap_bind: Inappropriate authentication (48)
additional info: anonymous bind disallowedVerbose Output
To display additional diagnostic information, use the -v option.
ldapwhoami -v -x -H ldap://ldap.example.com -D "uid=jdoe,ou=people,dc=example,dc=com" -WUsing SASL Authentication
If your LDAP environment uses SASL mechanisms such as GSSAPI (Kerberos), ldapwhoami can confirm the authenticated identity.
Example:
ldapwhoami -Y GSSAPI -H ldap://ldap.example.comdn:uid=jdoe,ou=people,dc=example,dc=comThis confirms the Kerberos-authenticated identity.
Troubleshooting Authentication
ldapwhoami is frequently used to diagnose authentication issues.
Common checks include:
- verifying credentials
- confirming SASL mappings
- validating TLS connections
- confirming authorization identity
Example troubleshooting command:
ldapwhoami -v -x -H ldaps://ldap.example.com -D "uid=jdoe,ou=people,dc=example,dc=com" -WCommon Errors
Invalid credentials
ldap_bind: Invalid credentials (49)The password or bind DN is incorrect.
Anonymous bind disallowed
ldap_bind: Inappropriate authentication (48)
additional info: anonymous bind disallowedCannot contact server
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)Possible causes include:
- network issues
- incorrect hostname
- TLS certificate problems
More information on using ldapwhoami can be found here.