From: cajus Date: Tue, 18 Aug 2009 07:25:24 +0000 (+0000) Subject: * Take care about ogroup references (Closes: #684) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=797ff469e7c5270d6ba5454cb4651c9b486c6a42;p=gosa.git * Take care about ogroup references (Closes: #684) git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14082 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index f3baf144d..45ffae7f4 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -120,7 +120,8 @@ class LDAP{ requests. I.e. member=.... */ static function prepare4filter($dn) { - return normalizeLdap(str_replace('\\\\', '\\\\\\', LDAP::fix($dn))); + $fixed= normalizeLdap(str_replace('\\\\', '\\\\\\', LDAP::fix($dn))); + return str_replace('\\,', '\\\\,', $fixed); } diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index f58df50bc..af6b60b1d 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -948,36 +948,20 @@ class plugin and check if there is an entry matching the source dn, if this is the case, then update this objectgroup to use the new dn. */ - $ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=*))","ogroups", + $ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","ogroups", array(get_ou("ogroupRDN")),$this->config->current['BASE'],array("member"), GL_SUBSEARCH | GL_NO_ACL_CHECK) ; - /* Walk through all objectGroups and check if there are - members matching the source dn - */ + // Walk through all objectGroups and check if there are members matching the source dn foreach($ogroups as $ogroup){ - if(isset($ogroup['member'])){ - /* Reset class object, this will be initialized with class_ogroup on demand - */ - $o_ogroup = NULL; - for($i = 0 ; $i < $ogroup['member']['count'] ; $i ++){ - $c_mem = $ogroup['member'][$i]; - if(preg_match("/".preg_quote($src_dn, '/')."$/i",$c_mem)){ - $d_mem = preg_replace("/".preg_quote($src_dn, '/')."$/i",$dst_dn,$ogroup['member'][$i]); - if($o_ogroup == NULL){ - $o_ogroup = new ogroup($this->config,$ogroup['dn']); - } - unset($o_ogroup->member[$c_mem]); - $o_ogroup->member[$d_mem]= $d_mem; - } - } - - /* Save object group if there were changes made on the membership */ - if($o_ogroup != NULL){ - $o_ogroup->save(); - } - } + // Migrate old to new dn + $o_ogroup= new ogroup($this->config,$ogroup['dn']); + unset($o_ogroup->member[$src_dn]); + $o_ogroup->member[$dst_dn]= $dst_dn; + + // Save object group + $o_ogroup->save(); } /* Update roles to use the new entry dn