diff --git a/trunk/includes/class/class.LSldap.php b/trunk/includes/class/class.LSldap.php index bc39fa53..39350745 100644 --- a/trunk/includes/class/class.LSldap.php +++ b/trunk/includes/class/class.LSldap.php @@ -186,14 +186,8 @@ class LSldap { public static function getEntry($object_type,$dn) { $obj_conf=LSconfig :: get('LSobjects.'.$object_type); if(is_array($obj_conf)){ - $entry = self :: $cnx -> getEntry($dn); - if (Net_LDAP2::isError($entry)) { - //$newentry = new Net_LDAP2_Entry(&self :: $cnx); - //$newentry -> dn($dn); - //$newentry -> add(array('objectclass' => $obj_conf['objectclass'])); - //foreach($obj_conf['attrs'] as $attr_name => $attr_conf) { - // $newentry->add(array($attr_name => $attr_conf['default_value'])); - //} + $entry = self :: getLdapEntry($dn); + if ($entry === false) { $attributes = array(); foreach($obj_conf['attrs'] as $attr_name => $attr_conf) { if( isset($attr_conf['default_value']) ) { @@ -218,6 +212,26 @@ class LSldap { } } + /** + * Retourne un object NetLDAP d'une entree existante + * + * @author Benjamin Renard + * + * @param[in] $dn string DN de l'entré Ldap + * + * @retval ldapentry|boolean Un objet ldapentry (PEAR::Net_LDAP2) ou false en + * cas de problème + */ + public static function getLdapEntry($dn) { + $entry = self :: $cnx -> getEntry($dn); + if (Net_LDAP2::isError($entry)) { + return false; + } + else { + return $entry; + } + } + /** * Retourne une nouvelle entrée *