如何在CentOS上以用户身份更改openldap密码?

原版的

我正在运行一个openldap-2.4.40身份validation系统,用户将能够更改他的密码。 使用dynamicconfiguration(意思是我没有使用slapd.conf进行configuration,而是使用cn=config目录中的文件),我尝试更改密码

 ldappasswd -x -D "uid=<my_user>,ou=Users,dc=<some>,dc=<dc>" -W -A -S 

这会提示我input旧密码(两次),然后input新密码,然后询问LDAP密码是否以错误消息结束: ldap_bind: Invalid credentials (49)

  1. 为什么命令要求我inputLDAP密码。 标准用户不应该知道密码
  2. 为什么程序终止凭证无效?

在我的/etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif我有以下设置为olcAccess

 olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage by * none 

我需要做什么以便用户能够更改他的密码?

编辑

回应SimonSchürg的回答,我添加了/etc/pam.d/passwd的内容:

 auth include system-auth account include system-auth password substack system-auth -password optional pam_gnome_keyring.so use_authtok password substack postlogin 

如果我用passwd更改密码,一切正常,我可以使用新密码login自己,但只能在运行LDAP服务器的计算机上login。 我无法login所有其他机器(“LDAP客户端”)。

EDIT2

对服务器和客户机上的用户或组执行的ldapsearch提供相同的输出。 但是, authconfig --test如果以root身份或用户身份执行,则testing输出会有所不同:

以root身份执行:

 nss_ldap is enabled LDAP+TLS is disabled LDAP server = "ldap://10.0.0.254" LDAP base DN = "dc=example,dc=com" pam_ldap is enabled LDAP+TLS is disabled LDAP server = "ldap://10.0.0.254" LDAP base DN = "dc=example,dc=com" LDAP schema = "rfc2307" 

以用户身份执行:

 nss_ldap is enabled LDAP+TLS is disabled LDAP server = "" LDAP base DN = "" pam_ldap is enabled LDAP+TLS is disabled LDAP server = "" LDAP base DN = "" LDAP schema = "rfc2307" 

如果答案的任何信息缺失,请让我知道,我将编辑问题,并提供您的信息。

如果您通过PAM全局启用LDAP身份validation并configuration/etc/pam.d/passwd ,则用户可以通过passwd命令更改自己的LDAP密码,如本地Unix帐户常见的那样。

我希望你已经能够用ldap用户login。

为了允许使用passwd命令进行密码更改,必须编辑/etc/pam.d/passwd并添加

 password sufficient pam_ldap.so use_authtok password required pam_deny.so 

——编辑——

您也可以使用authconfig在centos客户端上configurationldap,而不是手动编辑configuration文件。 以下命令以用户可以使用普通passwd命令更改密码的方式configurationLDAPvalidation。

 authconfig \ --enableldap \ --enableldapauth \ --ldapserver='ldap://example.com/' \ --ldapbasedn='dc=example,dc=com' \ --update 

也许你也想使用下面的标志来保存本地authentication和login时自动创build不存在的主目录。

  --enablemkhomedir \ --enableshadow \ --enablelocauthorize \ --passalgo=sha256 \ 

之前的命令运行authconfig --test后validation设置。
检查输出的以下部分:

 nss_ldap is enabled LDAP+TLS is disabled LDAP server = "ldap://example.com/" LDAP base DN = "dc=example,dc=com" pam_unix is always enabled shadow passwords are enabled password hashing algorithm is sha256 pam_ldap is enabled LDAP+TLS is disabled LDAP server = "ldap://example.com/" LDAP base DN = "dc=example,dc=com" LDAP schema = "rfc2307" pam_mkhomedir or pam_oddjob_mkhomedir is enabled (umask=0077) Always authorize local users is enabled () 

为用户更改密码现在很简单,如下所示:

 ldapuser@centos ~ % passwd Changing password for user ldapuser. (current) LDAP Password: New password: Retype new password: passwd: all authentication tokens updated successfully. ldapuser@centos ~ %