From 3362273688c45c175c428d3cffc2d473c434c7a4 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 15 Apr 2009 14:04:21 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSldap=20:=20=20=20->=20Ajout=20de=20la=20m?= =?UTF-8?q?=C3=A9thode=20getLdapEntry()=20=20=20->=20Utilisation=20de=20la?= =?UTF-8?q?=20m=C3=A9thode=20getLdapEntry()=20dans=20getEntry()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSldap.php | 30 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) 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 *