Ldap – Use ldapsearch to bind using short username

ldap

I am trying for more than 2 hours to find a way to use ldapsearch to connect to Microsoft Active Directory and I am not able to perform a successful bind.

I do not want to use the CN of my account (too long and contains unicode characters). I just want to use my login.

I was able to perform the same kind of login using other LDAP logins, using just my username or or prefixing it with the domain, like EXAMPLE.COM\johnd.

Still it seems that how-to do this is missing about ldapsearch.

Best Answer

Here is a working example:

ldapsearch -Z -LLL -H ldaps://example.com:3269 -x -y ~/.ldappass -D 'EXAMPLE\john' '(sAMAccountName=john)'

And .ldappass contains the password and nothing more. Even a newline after the password will break the login.