mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
- Correction bug [#1672] Les attributs vides ne sont pas supprimés
This commit is contained in:
parent
c6bcdfeafa
commit
6e8c58392d
1 changed files with 38 additions and 33 deletions
|
@ -176,11 +176,11 @@ class LSldap {
|
||||||
* @param[in] $dn string DN de l'entré Ldap
|
* @param[in] $dn string DN de l'entré Ldap
|
||||||
*
|
*
|
||||||
* @retval ldapentry|array Un objet ldapentry (PEAR::Net_LDAP2)
|
* @retval ldapentry|array Un objet ldapentry (PEAR::Net_LDAP2)
|
||||||
* ou un tableau (si c'est une nouvelle entrée):
|
* ou un tableau (si c'est une nouvelle entrée):
|
||||||
* Array (
|
* Array (
|
||||||
* 'entry' => ldapentry,
|
* 'entry' => ldapentry,
|
||||||
* 'new' => true
|
* 'new' => true
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
function getEntry($object_type,$dn) {
|
function getEntry($object_type,$dn) {
|
||||||
if(isset($GLOBALS['LSobjects'][$object_type])){
|
if(isset($GLOBALS['LSobjects'][$object_type])){
|
||||||
|
@ -189,17 +189,17 @@ class LSldap {
|
||||||
if (Net_LDAP2::isError($entry)) {
|
if (Net_LDAP2::isError($entry)) {
|
||||||
//$newentry = new Net_LDAP2_Entry(&$this -> cnx);
|
//$newentry = new Net_LDAP2_Entry(&$this -> cnx);
|
||||||
//$newentry -> dn($dn);
|
//$newentry -> dn($dn);
|
||||||
//$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
|
//$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
|
||||||
//foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
//foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
||||||
// $newentry->add(array($attr_name => $attr_conf['default_value']));
|
// $newentry->add(array($attr_name => $attr_conf['default_value']));
|
||||||
//}
|
//}
|
||||||
$attributes = array(
|
$attributes = array(
|
||||||
'objectclass' => $obj_conf['objectclass']
|
'objectclass' => $obj_conf['objectclass']
|
||||||
);
|
);
|
||||||
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
||||||
if( isset($attr_conf['default_value']) ) {
|
if( isset($attr_conf['default_value']) ) {
|
||||||
$attributes[$attr_name]=$attr_conf['default_value'];
|
$attributes[$attr_name]=$attr_conf['default_value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$newentry = Net_LDAP2_Entry::createFresh($dn,$attributes);
|
$newentry = Net_LDAP2_Entry::createFresh($dn,$attributes);
|
||||||
|
|
||||||
|
@ -231,14 +231,14 @@ class LSldap {
|
||||||
function update($object_type,$dn,$change) {
|
function update($object_type,$dn,$change) {
|
||||||
debug($change);
|
debug($change);
|
||||||
$dropAttr=array();
|
$dropAttr=array();
|
||||||
$entry=$this -> getEntry($object_type,$dn);
|
$entry=$this -> getEntry($object_type,$dn);
|
||||||
if (is_array($entry)) {
|
if (is_array($entry)) {
|
||||||
$new = $entry['new'];
|
$new = $entry['new'];
|
||||||
$entry = $entry['entry'];
|
$entry = $entry['entry'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$new = false;
|
$new = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($entry) {
|
if($entry) {
|
||||||
foreach($change as $attrName => $attrVal) {
|
foreach($change as $attrName => $attrVal) {
|
||||||
|
@ -265,23 +265,28 @@ class LSldap {
|
||||||
debug('change : <pre>'.print_r($changeData,true).'</pre>');
|
debug('change : <pre>'.print_r($changeData,true).'</pre>');
|
||||||
debug('drop : <pre>'.print_r($dropAttr,true).'</pre>');
|
debug('drop : <pre>'.print_r($dropAttr,true).'</pre>');
|
||||||
|
|
||||||
if ($new) {
|
if ($new) {
|
||||||
$ret = $this -> cnx -> add($entry);
|
$ret = $this -> cnx -> add($entry);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ret = $entry -> update();
|
$ret = $entry -> update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Net_LDAP2::isError($ret)) {
|
if (Net_LDAP2::isError($ret)) {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
|
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
|
||||||
debug('NetLdap-Error : '.$ret->getMessage());
|
debug('NetLdap-Error : '.$ret->getMessage());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!empty($dropAttr)) {
|
if (!empty($dropAttr)) {
|
||||||
foreach($dropAttr as $attr) {
|
foreach($dropAttr as $attr) {
|
||||||
$entry -> delete($attr);
|
$entry -> delete($attr);
|
||||||
}
|
}
|
||||||
}
|
$ret = $entry -> update();
|
||||||
|
if (Net_LDAP2::isError($ret)) {
|
||||||
|
debug('Erreur durant la suppression des attributs vides');
|
||||||
|
debug('NetLdap-Error : '.$ret->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue