简体   繁体   中英

ldapsearch with -y option throws 'Invalid credentials' error

I have kept my LDAP password in $HOME/.ldap_pw on my Mac. The file has permissions set to 600:

-rw-------  1 myself  mygroup  18 Mar 27 17:20 .ldap_pw

When I invoke ldapsearch with -y option like this, to list the members of the group mygroup

ldapsearch -y "$HOME/.ldap_pw" -H ldaps://ldap.mycompany.com -D myself@mycompany.com -W -b DC=mycompany,DC=com -x '(&(objectcategory=Group)(cn=mygroup))'

I get this error:

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

The password stored in the file is correct. Also, the above command works fine when run without the -y option with password being entered when prompted.

What is going wrong here?

I get the same error on my Linux box running RedHat 7.6.

Given the error, that means that the username is valid but password invalid (see ldapwiki.com ) and the fact that -y use the complete contents of the file (see ldapsearch documentation ), I suspect a wrong content in your password file. Maybe an "End of line" character at the end of your file.

I think SmartTom's guess about an extra character in the file is a good one. Try running hd ~/.ldap_pw ( h ex d ump) to see the exact contents of the file; if there's a trailing 0a (newline) character or other unexpected characters that would confirm the issue.

Editors like vim implicitly add a trailing newline to text files, which you can disable when opening the file, or you can remove trailing whitespace directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM