在 OpenLDAP 2.4.32 和 PHP 5.4.6 中使用 ldap_modify 时出现访问不足错误。
给出错误的 php 函数如下所示:
function set_user($dn, $password, $data)
{
/* This function sets the users infomation */
// Get Configuration Items
$ldapServer = $this->config->item('ldapServer');
$ldapDCRoot = $this->config->item('ldapDCRoot');
// Connect to LDAP
$ldapConnection = ldap_connect($ldapServer);
if($ldapConnection)
{
$r = ldap_bind($ldapConnection, $dn, $password);
if ($r)
{
// Bind completed successfully
$r = ldap_modify($ldapConnection, $dn, $data);
return True;
}
die("Unsuccessful Bind");
}
die("Can't connect to LDAP");
}
$dn 是尝试更改其信息及其密码的用户的完整 DN。$data 是他们正在更新的值,现在 data 只包含要更改的电话号码 $data['mobile'] = "newPhoneNumber"。除了数据从未实际写入之外,这一切似乎都在工作。
openldap 文件包含在下面,您可以看到 ACL 说我应该能够写入它。
include /etc/openldap/schema/corba.schema
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/duaconf.schema
include /etc/openldap/schema/dyngroup.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/java.schema
include /etc/openldap/schema/misc.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/ppolicy.schema
include /etc/openldap/schema/collective.schema
allow bind_v2
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
TLSCertificateFile /etc/pki/tls/certs/slapd.pem
TLSCertificateKeyFile /etc/pki/tls/certs/slapd.pem
access to *
by self write
by users read
by anonymous auth
database bdb
suffix "dc=example,dc=com"
checkpoint 1024 15
rootdn "cn=manager,dc=example,dc=com"
rootpw REDACTED
directory /var/lib/ldap
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub
问题是为什么 PHP 不能更新值,而是得到一个访问不足的错误?