ldapsearch not accepting password with -w

I'm trying to use the ldapsearch command to query an LDAP server. I can authenticate correctly when I use the -W option, which prompts for the password that I paste in. However when I use the -w option (to avoid keeping on pasting the password), it fails.

So the command that works is:

ldapsearch -x -h ldap.myorg -D myusername -W -b DC=com,DC=myorg "(sAMAccountName=userlookingfor)"

But it doesn't work when I do:

ldapsearch -x -h ldap.myorg -D myusername -w mypassword -b DC=com,DC=myorg "(sAMAccountName=userlookingfor)"

I get the error:

ldap_bind: Invalid credentials (49) additional info: 80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580

The password does contain special characters, however I've tried putting the password in quotes which didn't work either.

1 Answer

If you use bash, did you try to put the password in single quotes like the following? :

-w 'p@$sW0rD'

Or you can use the form $'string' to express special characters. If your password is pass\word, you can do like the following:

-w pass$'\\'word

or

-w pass$'\x5c'word
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like