在我的PHP脚本中,我写了一个函数,使用户能够更改他们的openldap密码,我使用了php函数,如ldap_connect,ldap_bind,ldap_search,ldap_modify。
首先我想,也许最好给每个用户提供访问权限来更改自己的密码,但是对于ldap_bind这种方式,我们仍然需要用户pipe理员用户凭证来成功绑定。 所以我想创build一个新的用户可以绑定和更改每个人的密码,所以我不必在代码中的用户pipe理员。
我创build了这些ldif文件
superuser.ldif:
dn: cn=superuser,dc=test,dc=com cn: superuser objectClass: simpleSecurityObject objectClass: organizationalRole description: LDAP write password user userPassword: {crypt}superuserpass
超级用户acl.ldif
dn: olcDatabase={1}hdb,cn=config changetype: modify delete: olcAccess - add: olcAccess olcAccess: to attrs=userPassword,shadowLastChange by dn="cn=superuser,dc=test,dc=com" write
我用这些命令应用ldif文件:
ldapadd -x -H ldap://openldap.localhost -w ldapadminpass -D "cn=admin,dc=test,dc=com" -f /ldif/superuser.ldif
和
ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f /ldif/superuser-acl.ldif
但使用以下命令从php服务器执行ldapsearch后:
ldapsearch -H ldap://openldap.localhost -D "cn=superuser,dc=test,dc=com" -w superuserpass -x -b "ou=people,dc=test,dc=com" mail uid
它给了我这个错误:
ldap_bind: Invalid credentials (49)
我得到这个日志slapd -d "acl, trace"
Backend ACL: access to * by dn.base="cn=superuser,dc=test,dc=com" write 595ceadf /etc/ldap/slapd.d: line 1: warning: cannot assess the validity of the ACL scope within backend naming context
有没有更好的方法来解决这个问题? 我正在阅读slapd文档,但无法弄清楚为什么我的acl不能正常工作。
感谢任何帮助
谢谢