Code

Update role entries when renaming ldap entries.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Jul 2009 07:06:37 +0000 (07:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Jul 2009 07:06:37 +0000 (07:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13896 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_plugin.inc

index 5a5b89301acf6016f4bffe5837826da4ed6ec9a6..f58df50bc33d19a46ec9aa802fbeb7934a3d6f22 100644 (file)
@@ -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.