From 03961c7320b9cbbe5724e12b388843298c644bf8 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 7 Jul 2009 07:06:37 +0000 Subject: [PATCH] Update role entries when renaming ldap entries. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13896 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_plugin.inc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 5a5b89301..f58df50bc 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -962,17 +962,12 @@ class plugin */ $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; } @@ -984,6 +979,21 @@ class plugin } } } + + /* Update roles to use the new entry dn + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=organizationalRole)". + "(roleOccupant=".LDAP::prepare4filter($src_dn)."))"); + while($attrs = $ldap->fetch()){ + $role = new roleGeneric($this->config,$attrs['dn']); + $key = array_search($src_dn,$role->roleOccupant); + if($key !== FALSE){ + $role->roleOccupant[$key] = $dst_dn; + $role->save(); + } + } /* Check if there are gosa departments moved. If there were deps moved, the force reload of config->deps. -- 2.30.2