X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_plugin.inc;h=0691c206073d220480c29269e45c8d395ee68038;hb=30d939bbc772a9b8cdd9704e8034101e957ab972;hp=ddd00c55ad105ea00426d63af68816b305e349f9;hpb=c7ce835ef689103c537e755559b00129cf0ef825;p=gosa.git diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index ddd00c55a..0691c2060 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -139,7 +139,7 @@ class plugin \param dn Distinguished name to initialize plugin from \sa plugin() */ - function plugin (&$config, $dn= NULL, $parent= NULL) + function plugin (&$config, $dn= NULL, $object= NULL) { /* Configuration is fine, allways */ $this->config= &$config; @@ -167,8 +167,8 @@ class plugin if ($dn !== NULL){ /* Load data to 'attrs' and save 'dn' */ - if ($parent !== NULL){ - $this->attrs= $parent->attrs; + if ($object !== NULL){ + $this->attrs= $object->attrs; } else { $ldap= $this->config->get_ldap_link(); $ldap->cat ($dn); @@ -746,6 +746,39 @@ class plugin } } + + /* Create unique DN */ + function create_unique_dn2($data, $base) + { + $ldap= $this->config->get_ldap_link(); + $base= preg_replace("/^,*/", "", $base); + + /* Try to use plain entry first */ + $dn= "$data,$base"; + $attribute= preg_replace('/=.*$/', '', $data); + $ldap->cat ($dn, array('dn')); + if (!$ldap->fetch()){ + return ($dn); + } + + /* Look for additional attributes */ + foreach ($this->attributes as $attr){ + if ($attr == $attribute || $this->$attr == ""){ + continue; + } + + $dn= "$data+$attr=".$this->$attr.",$base"; + $ldap->cat ($dn, array('dn')); + if (!$ldap->fetch()){ + return ($dn); + } + } + + /* None found */ + return ("none"); + } + + /* Create unique DN */ function create_unique_dn($attribute, $base) { @@ -776,6 +809,7 @@ class plugin return ("none"); } + function rebind($ldap, $referral) { $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']); @@ -853,6 +887,9 @@ class plugin /* FAIvariable=.../..., cn=.. could not be saved, because the attribute FAIvariable was different to the dn FAIvariable=..., cn=... */ + + if(!is_array($new['objectClass'])) $new['objectClass'] = array($new['objectClass']); + if(in_array_ics("FAIdebconfInfo",$new['objectClass'])){ $new['FAIvariable'] = $ldap->fix($new['FAIvariable']); } @@ -942,7 +979,7 @@ class plugin array("dn","objectClass"),GL_SUBSEARCH | GL_NO_ACL_CHECK); foreach($leaf_objs as $obj){ $new_dn = $obj['dn']; - $old_dn = preg_replace("/".preg_quote($dst_dn, '/')."$/i",$src_dn,$new_dn); + $old_dn = preg_replace("/".preg_quote(LDAP::convert($dst_dn), '/')."$/i",$src_dn,LDAP::convert($new_dn)); $this->update_acls($old_dn,$new_dn); } @@ -953,7 +990,9 @@ class plugin foreach($ogroups as $ogroup){ // Migrate old to new dn $o_ogroup= new ogroup($this->config,$ogroup['dn']); - unset($o_ogroup->member[$src_dn]); + if (isset($o_group->member[$src_dn])) { + unset($o_ogroup->member[$src_dn]); + } $o_ogroup->member[$dst_dn]= $dst_dn; // Save object group @@ -961,16 +1000,13 @@ class plugin } // Migrate rfc groups if needed - $groups = get_sub_list("(&(objectClass=posixGroups)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","groups", array(get_ou("groupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK); + $groups = get_sub_list("(&(objectClass=posixGroup)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","groups", array(get_ou("groupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK); // Walk through all POSIX groups foreach($groups as $group){ + // Migrate old to new dn $o_group= new group($this->config,$group['dn']); - unset($o_group->member[$src_dn]); - $o_group->member[$dst_dn]= $dst_dn; - - // Save object group $o_group->save(); } @@ -1116,11 +1152,8 @@ class plugin if (isset($source[$var])){ if(isset($source[$var]['count'])){ if($source[$var]['count'] > 1){ - $this->$var = array(); - $tmp = array(); - for($i = 0 ; $i < $source[$var]['count']; $i++){ - $tmp = $source[$var][$i]; - } + $tmp= $source[$var]; + unset($tmp['count']); $this->$var = $tmp; }else{ $this->$var = $source[$var][0];