douyong1285 2016-05-23 23:45
浏览 203

无法使用ldap_mod_replace替换任何属性

I'm trying to build a self-service portal onto my OpenLDAP server so that users can update their GECOS entry, phone number, etc. They will NOT be updating their password per requirements.

The problem is I'm not able to update any attributes in the LDAP server. I use the PHP call ldap_mod_replace with a valid DN (the root administrative DN right now) to update these attributes. The error I receive is:

(53) Server is unwilling to perform

The bind is successful to the server. Using the same bind DN I am able to update any attribute I wish to using a third party tool (JXplorer).

Here is a snip of the exact code where the update is performed, redacted for protecting IP:

function saveAccountData($connection, $dn, $newAcctData, $isAdmin = false) {
    $permittedData = array();
    $resp = ldap_bind($connection, "cn=rootdn,dc=domain,dc=tld", "reallygoodpassword");
    if (!$resp) {
        die("Failed to bind to LDAP with authenticated credentials! $resp
");
    }
    if ($isAdmin) {
        $permittedData = $newAcctData;
    }
    else {
        $permittedData["homedirectory"] = $newAcctData["homeDirectory"];
        $permittedData["gecos"] = $newAcctData["gecos"];
        $permittedData["loginshell"] = $newAcctData["loginShell"];
        $permittedData["telephonenumber"] = $newAcctData["telephoneNumber"];
    }
    return ldap_mod_replace($connection, $dn, $permittedData);
}

I check for the error outside after calling this function, which is how I arrived here with the error message.

I referred to this manual: http://www.openldap.org/doc/admin24/appendix-common-errors.html

I've reviewed the several topics, but these seem to apply to Active Directory: ldap_mod_replace() [function.ldap-mod-replace]: Modify: Server is unwilling to perform

I've still tried these solutions, but to no avail. What is going wrong here?

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dongyi1777 2016-05-28 11:43
    关注

    The ldap_mod_replace should be used to change a value or multiple values of a single attribute type only. You should use ldap_modify to update multiple attribute types in a single LDAP modify operation.

    The manual is likely somewhat confusing as ldap_mod_replace takes an argument that led you believe that changing multiple attribute types with this method is allowed. It is not.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法