mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 14:33:49 +01:00
- bug Addons Samba - Génération uidnumber
- [#1663] Error when adding a person : adaptation à la version 2 de Net_LDAP
This commit is contained in:
parent
7383def59b
commit
03edde1437
2 changed files with 49 additions and 17 deletions
|
@ -138,7 +138,9 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uidNumber = $ldapObject -> attrs[ LS_SAMBA_UIDNUMBER_ATTR ] -> getValue() * 2 + LS_SAMBA_SID_BASE_USER;
|
$uidnumber_attr_val = $ldapObject -> attrs[ LS_SAMBA_UIDNUMBER_ATTR ] -> getValue();
|
||||||
|
$uidnumber_attr_val = $uidnumber_attr_val[0];
|
||||||
|
$uidNumber = $uidnumber_attr_val * 2 + LS_SAMBA_SID_BASE_USER;
|
||||||
$sambaSID = LS_SAMBA_DOMAIN_SID . '-' . $uidNumber;
|
$sambaSID = LS_SAMBA_DOMAIN_SID . '-' . $uidNumber;
|
||||||
|
|
||||||
return ($sambaSID);
|
return ($sambaSID);
|
||||||
|
|
|
@ -175,20 +175,35 @@ class LSldap {
|
||||||
* @param[in] $object_type string Type de l'objet Ldap
|
* @param[in] $object_type string Type de l'objet Ldap
|
||||||
* @param[in] $dn string DN de l'entré Ldap
|
* @param[in] $dn string DN de l'entré Ldap
|
||||||
*
|
*
|
||||||
* @retval ldapentry 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):
|
||||||
|
* Array (
|
||||||
|
* 'entry' => ldapentry,
|
||||||
|
* 'new' => true
|
||||||
|
* )
|
||||||
*/
|
*/
|
||||||
function getEntry($object_type,$dn) {
|
function getEntry($object_type,$dn) {
|
||||||
if(isset($GLOBALS['LSobjects'][$object_type])){
|
if(isset($GLOBALS['LSobjects'][$object_type])){
|
||||||
$obj_conf=$GLOBALS['LSobjects'][$object_type];
|
$obj_conf=$GLOBALS['LSobjects'][$object_type];
|
||||||
$entry = $this -> cnx -> getEntry($dn);
|
$entry = $this -> cnx -> getEntry($dn);
|
||||||
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(
|
||||||
|
'objectclass' => $obj_conf['objectclass']
|
||||||
|
);
|
||||||
|
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
||||||
|
if( isset($attr_conf['default_value']) ) {
|
||||||
|
$attributes[$attr_name]=$attr_conf['default_value'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $newentry;
|
$newentry = Net_LDAP2_Entry::createFresh($dn,$attributes);
|
||||||
|
|
||||||
|
return array('entry' => $newentry,'new' => true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $entry;
|
return $entry;
|
||||||
|
@ -216,7 +231,16 @@ class LSldap {
|
||||||
function update($object_type,$dn,$change) {
|
function update($object_type,$dn,$change) {
|
||||||
debug($change);
|
debug($change);
|
||||||
$dropAttr=array();
|
$dropAttr=array();
|
||||||
if($entry=$this -> getEntry($object_type,$dn)) {
|
$entry=$this -> getEntry($object_type,$dn);
|
||||||
|
if (is_array($entry)) {
|
||||||
|
$new = $entry['new'];
|
||||||
|
$entry = $entry['entry'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$new = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($entry) {
|
||||||
foreach($change as $attrName => $attrVal) {
|
foreach($change as $attrName => $attrVal) {
|
||||||
$drop = true;
|
$drop = true;
|
||||||
if (is_array($attrVal)) {
|
if (is_array($attrVal)) {
|
||||||
|
@ -238,20 +262,26 @@ class LSldap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$entry -> replace($changeData);
|
$entry -> replace($changeData);
|
||||||
debug('change : '.print_r($changeData,true));
|
debug('change : <pre>'.print_r($changeData,true).'</pre>');
|
||||||
debug('drop : '.print_r($dropAttr,true));
|
debug('drop : <pre>'.print_r($dropAttr,true).'</pre>');
|
||||||
|
|
||||||
$ret = $entry -> update();
|
if ($new) {
|
||||||
if (!empty($dropAttr)) {
|
$ret = $this -> cnx -> add($entry);
|
||||||
foreach($dropAttr as $attr) {
|
}
|
||||||
$entry -> delete($attr);
|
else {
|
||||||
}
|
$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)) {
|
||||||
|
foreach($dropAttr as $attr) {
|
||||||
|
$entry -> delete($attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue