带有 -y 选项的 ldapsearch 抛出 'Invalid credentials' 错误

ldapsearch with -y option throws 'Invalid credentials' error

我在 Mac 上的 $HOME/.ldap_pw 中保存了我的 LDAP 密码。该文件的权限设置为 600:

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

当我像这样使用 -y 选项调用 ldapsearch 时,列出组 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))'

我收到这个错误:

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

保存在文件中的密码是正确的。此外,上述命令在 运行 没有 -y 选项时工作正常,并在提示时输入密码。

这里出了什么问题?

我在 Linux box 运行ning RedHat 7.6 上遇到同样的错误。

鉴于错误,这意味着用户名有效但密码无效(参见ldapwiki.com) and the fact that -y use the complete contents of the file (see ldapsearch documentation),我怀疑您的密码文件中的内容有误。文件末尾可能有一个 "End of line" 字符。

我认为 SmartTom 对文件中额外字符的猜测是正确的。尝试 运行 hd ~/.ldap_pw (hex dump) 查看文件的确切内容;如果尾随 0a(换行符)字符或其他意外字符可以确认问题。

vim 这样的编辑器会在文本文件中隐式地添加尾随换行符,您可以直接 disable when opening the file, or you can remove trailing whitespace