2013-06-04 30 views
1

PHP ldap_mod_replace失敗,«型號或價值存在,»我已經在PHP的API從Active Directory對象緩解管理層創造了燈型號經理LDAP錯誤

一切都正常運行,但我有一個問題,當即使我改變所有的值更新多值屬性,交易與失敗«類型或值存在»錯誤和屬性沒有在數據庫中更改。

我使用的測試用例是改變去多有價值的「描述」字段的用戶。如果我添加新值或更改整個值的數組,事務總是失敗。

代碼的部分如下:

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))));                                    
    }                      

的完整代碼可以發現[此處在github](https://github.com/chanmix51/SlapOM/blob/master/lib/SlapOM/Connection.php#L115 [GitHub的])。

該日誌顯示下列行:

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 
     ) 
)} 

即使前述值分別爲["description" => ['Description 1']]。有沒有我沒有得到或做錯的事情?

回答

1

答案是矮:«說明是不是多值字段»。像往常一樣,錯誤信息是如此混亂,它導致我花了幾個小時在錯誤的問題。

簡而言之:LDAP錯誤20「類型或值存在」可能是您試圖在多值字段中插入兩次相同的值,或者您嘗試在單值字段中插入多個值。

相關問題