mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +01:00
LSldap: fix updating internal attributes
LSldap::getEntry method now list expected attributes when using the LSldap::getLdapEntry method. This method now also accept a new $attrs attribute to specify expected attributes list.
This commit is contained in:
parent
9c53608fa2
commit
9d3e69c86d
1 changed files with 28 additions and 21 deletions
|
@ -272,27 +272,28 @@ class LSldap extends LSlog_staticLoggerClass {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retourne une entrée existante ou nouvelle
|
||||
* Return an existing or new LDAP entry
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $object_type string Type de l'objet Ldap
|
||||
* @param[in] $dn string DN de l'entré Ldap
|
||||
* @param[in] $object_type string The object type
|
||||
* @param[in] $dn string The DN of the LDAP entry
|
||||
*
|
||||
* @retval ldapentry|array Un objet ldapentry (PEAR::Net_LDAP2)
|
||||
* ou un tableau (si c'est une nouvelle entr<EFBFBD>e):
|
||||
* @retval ldapentry|array A Net_LDAP2_Entry object or an array if
|
||||
* it's a new entry:
|
||||
* Array (
|
||||
* 'entry' => ldapentry,
|
||||
* 'entry' => Net_LDAP2_Entry,
|
||||
* 'new' => true
|
||||
* )
|
||||
*/
|
||||
public static function getEntry($object_type,$dn) {
|
||||
public static function getEntry($object_type, $dn) {
|
||||
$obj_classes = LSconfig :: get("LSobjects.$object_type.objectclass");
|
||||
if(!is_array($obj_classes)){
|
||||
LSerror :: addErrorCode('LSldap_03');
|
||||
return;
|
||||
}
|
||||
$entry = self :: getLdapEntry($dn);
|
||||
$attrs = array_keys(LSconfig :: get("LSobjects.$object_type.attrs", array(), 'array'));
|
||||
$entry = self :: getLdapEntry($dn, $attrs);
|
||||
if ($entry === false) {
|
||||
$newentry = self :: getNewEntry($dn, $obj_classes, array());
|
||||
if (!$newentry) {
|
||||
|
@ -310,17 +311,17 @@ class LSldap extends LSlog_staticLoggerClass {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retourne un object NetLDAP d'une entree existante
|
||||
* Return a Net_LDAP2_Entry object of an existing entry
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $dn string DN de l'entré Ldap
|
||||
* @param[in] $dn string DN of the requested LDAP entry
|
||||
* @param[in] $attrs array|null Array of requested attribute (optional, default: null == all attributes, excepted internal)
|
||||
*
|
||||
* @retval ldapentry|boolean Un objet ldapentry (PEAR::Net_LDAP2) ou false en
|
||||
* cas de probl<EFBFBD>me
|
||||
* @retval ldapentry|boolean A Net_LDAP2_Entry object or false if error occured
|
||||
*/
|
||||
public static function getLdapEntry($dn) {
|
||||
$entry = self :: $cnx -> getEntry($dn);
|
||||
public static function getLdapEntry($dn, $attrs=null) {
|
||||
$entry = self :: $cnx -> getEntry($dn, (is_array($attrs)?$attrs:array()));
|
||||
if (Net_LDAP2::isError($entry)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -343,16 +344,22 @@ class LSldap extends LSlog_staticLoggerClass {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retourne une nouvelle entr<EFBFBD>e
|
||||
* Return a new Net_LDAP2_Entry object
|
||||
*
|
||||
* @param[in] $dn string Le DN de l'objet
|
||||
* @param[in] $objectClass array Un tableau contenant les objectClass de l'objet
|
||||
* @param[in] $attrs array Un tabeau du type array('attr_name' => attr_value, ...)
|
||||
* @param[in] $dn string The DN of the object
|
||||
* @param[in] $objectClass array Array of the object's object classes
|
||||
* @param[in] $attrs array Array of object attributes values. Format: array('attr_name' => attr_value, ...)
|
||||
*
|
||||
* @retval mixed Le nouvelle objet en cas de succ<EFBFBD>s, false sinon
|
||||
* @retval Net_LDAP2_Entry|False A Net_LDAP2_Entry object on success, False otherwise
|
||||
*/
|
||||
public static function getNewEntry($dn,$objectClass,$attrs,$add=false) {
|
||||
$newentry = Net_LDAP2_Entry::createFresh($dn,array_merge(array('objectclass' =>$objectClass),(array)$attrs));
|
||||
public static function getNewEntry($dn, $objectClass, $attrs, $add=false) {
|
||||
$newentry = Net_LDAP2_Entry::createFresh(
|
||||
$dn,
|
||||
array_merge(
|
||||
array('objectclass' =>$objectClass),
|
||||
ensureIsArray($attrs)
|
||||
)
|
||||
);
|
||||
if(Net_LDAP2::isError($newentry)) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue