[英]PHP Warning: ldap_modify(): Modify: Operation not allowed on RDN
[英]PHP ldap_modify Insufficient access
我使用ldap_modify与OpenLDAP 2.4.32和PHP 5.4.6获得的访问错误不足。
给出错误的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 ['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不能更新值而不是访问错误?
为了调试您的问题,我建议使用命令行工具ldapmodify来发出相同的请求。 您可能需要将其安装到您的系统(Redhat openldap-clients
,Debian slapd
)。
通过设置调试级别-d
您可以获得比php库提供的有关您的调用返回不充分访问错误的原因的更多信息。
虽然我从来没有用ldapmodify来做这件事,但我已经将它与ldapsearch一起使用并取得了巨大的成功。 所以它可能需要一些搜索或ldapmodify --help
帮助找出如何使用它。
我想这个命令看起来像这样:
ldapmodify -d 7 -h ldap.server.com -D bind_dn -w bind_password -f /tmp/entrymods
在更改Active Directory密码时我遇到了一些问题。 也许这也有助于其他人:
第1名:您将需要安全连接,否则LDAP将拒绝更改密码。
$this->ldap_ds = ldap_connect($this->hostname);
//some protocol options
ldap_set_option($this->ldap_ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option($this->ldap_ds, LDAP_OPT_PROTOCOL_VERSION, 3);
// start secure connection on port 636
ldap_start_tls($this->ldap_ds);
第二:在我的系统上,我在启动安全连接时遇到了问题,我现在解决了这个问题,现在编辑/etc/ldap/ldap.conf
# TLS_CACERT /etc/ssl/certs/ca-certificates.crt
TLS_REQCERT never
3rd:对于活动目录,我们使用unicodePwd
字段而不是userPassword
字段。 此字段需要Unicode中的String。
$entry["unicodePwd"] = iconv("UTF-8", "UTF-16LE", '"' . $newPassword . '"');
第四:要更改密码,不能使用modify
而应使用mod_replace
函数。
ldap_mod_replace($ldapConnection, $user_dn, $entry);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.