Easy way to test an LDAP User's Credentials

directory, ldap, opendj, opends

Solution

`ldapwhoami -vvv -h <hostname> -p <port> -D <binddn> -x -w <passwd>`, where `binddn` is the DN of the person whose credentials you are authenticating.

On success (i.e., valid credentials), you get `Result: Success (0)`. On failure, you get `ldap_bind: Invalid credentials (49)`.

Problem

Is there an easy way to test the credentials of a user against an LDAP instance? I know how to write a Java program that would take the 'User DN' and password, and check it against the LDAP instance. However is there any easier way? Specially a method that not only authenticates the user, but also lists all the user's roles.

Original source