doumei1203 2013-06-04 09:18
浏览 93
已采纳

PHP ldap_mod_replace失败,出现“存在类型或值”错误

I have created a light Model Manager for LDAP over PHP's API to ease object managements from Active Directory.

Everything runs fine but I have a problem when updating multi valued attributes even if I change all the values, the transaction fails with «Type or value exists» error and the attribute is not changed in the database.

The test case I am using is to change de multi valued "description" field for a user. If I add new values or change the whole array of values, the transaction always fail.

The part of the code is the following:

    if (count($mod_attr) > 0)                                                                                                                                                                                                             
    {                                                                                                                                                                                                                                     
        $ret = @ldap_mod_replace($this->getHandler(), $dn, $mod_attr);                                                                                                                                                                    
        if ($ret === false)                                                                                                                                                                                                               
        {                                                                                                                                                                                                                                                 $this->log(sprintf("LDAP ERROR '%s' -- Modifying {%s}.", ldap_error($this->getHandler()), print_r($mod_attr, true)), \SlapOM\LoggerInterface::LOGLEVEL_CRITICAL);                                                             

            throw new LdapException(sprintf("Error while MODIFYING values <pre>%s</pre> in dn='%s'.", print_r($mod_attr, true), $dn), $this->getHandler(), $this->error);                                                                 
        }                                                                                                                                                                                                                                 

        $this->log(sprintf("Changing attribute {%s}.", join(', ', array_keys($mod_attr))));                                                                                                                                               
    }                                                                                       

The complete code can be found [here on github](https://github.com/chanmix51/SlapOM/blob/master/lib/SlapOM/Connection.php#L115 [github]).

The logs show the following lines:

   2013-06-04 10:39:54 |                => MODIFY dn='CN=HUBERT Gregoire,OU=...
   2013-06-04 10:39:54 | => LDAP ERROR 'Type or value exists' -- Modifying {Array
(   
    [description] => Array
        (   
            [0] => Description 2
            [1] => Description 3
        )
)}

Even if the preceding values were ["description" => ['Description 1']]. Is there something I am not getting or doing wrong ?

  • 写回答

1条回答 默认 最新

  • dsfdfdfd6576578 2013-06-04 10:25
    关注

    The answer is short: «Description is not a multi valued field». As usual, the error message was so confusing, it lead me to spend hours on the wrong problem.

    In short: the LDAP error 20 «Type or value exists» can be either you are trying to insert twice the same values in a multi valued field or you are trying to insert several values in a single valued field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘