Code

Updated get_ou it receives values from the config registry now.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 10 May 2010 13:32:34 +0000 (13:32 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 10 May 2010 13:32:34 +0000 (13:32 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18262 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_CopyPasteHandler.inc
gosa-core/include/class_config.inc
gosa-core/include/class_plugin.inc
gosa-core/include/functions.inc

index 5d83308418693cb9e1b529bd53d71660b8797922..586f3b11eb57d31a6bf3221c8e2c2fdf7fdc0ad6 100644 (file)
@@ -516,7 +516,7 @@ class CopyPasteHandler {
 
     // Migrate objectgroups
     $ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
-            "ogroups", array(get_ou("ogroupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+            "ogroups", array(get_ou("core", "groupRDN") ),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
     // Walk through all objectGroups
     foreach($ogroups as $ogroup){
@@ -527,7 +527,7 @@ class CopyPasteHandler {
 
     // Update roles 
     $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
-            "roles", array(get_ou("roleRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+            "roles", array(get_ou("core", "groupRDN") ),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
     // Walk through all roles
     foreach($roles as $role){
@@ -548,7 +548,7 @@ class CopyPasteHandler {
 
             $uid = $this->current['object']->uid;
             $groups = get_sub_list("(&(objectClass=posixGroup)(memberUid={$suid}))",
-                    "groups",array(get_ou("groupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+                    "groups",array(get_ou("core", "groupRDN") ),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
             // Walk through all POSIX groups
             foreach($groups as $group){
index e50de7e22e022610ba36d91feb7e65cc632abcb2..97c032ce3726d844c4a7debeab1b1499ff3d1496 100644 (file)
@@ -866,7 +866,7 @@ class config  {
    */
   function getShareList($listboxEntry = false)
   {
-    $tmp = get_sub_list("(&(objectClass=goShareServer)(goExportEntry=*))","server",get_ou("serverRDN"),
+    $tmp = get_sub_list("(&(objectClass=goShareServer)(goExportEntry=*))","server",get_ou("servgeneric", "serverRDN") ,
         $this->current['BASE'],array("goExportEntry","cn"), GL_NONE);
     $return =array();
     foreach($tmp as $entry){
@@ -908,7 +908,7 @@ class config  {
     $ui = get_userinfo();
     $base = $config->current['BASE'];
     $res= get_sub_list("(&(objectClass=goShareServer)(goExportEntry=*))", "server",
-          get_ou("serverRDN"), $base,array("goExportEntry","cn"),GL_NONE | GL_NO_ACL_CHECK);
+          get_ou("servgeneric", "serverRDN") , $base,array("goExportEntry","cn"),GL_NONE | GL_NO_ACL_CHECK);
 
     foreach($res as $entry){
         
index 1b45db134f9d88a81b8c7421af14293805132468..6e7ec7c85fb3431ca09f8d1e8ec0fb3e4959cd85 100644 (file)
@@ -860,7 +860,7 @@ class plugin
 
     // Migrate objectgroups if needed
     $ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
-      "ogroups", array(get_ou("ogroupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+      "ogroups", array(get_ou("core", "groupRDN") ),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
     // Walk through all objectGroups
     foreach($ogroups as $ogroup){
@@ -876,7 +876,7 @@ class plugin
     }
 
     // Migrate rfc groups if needed
-    $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);
+    $groups = get_sub_list("(&(objectClass=posixGroup)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","groups", array(get_ou("core", "groupRDN") ),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
     // Walk through all POSIX groups
     foreach($groups as $group){
@@ -887,7 +887,7 @@ class plugin
     }
 
     /* Update roles to use the new entry dn */
-    $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","roles", array(get_ou("roleRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+    $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","roles", array(get_ou("core", "groupRDN") ),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
     // Walk through all roles
     foreach($roles as $role){
index e7637663a920f936934e2ef2f586673fb0eddfd5..23badf7125b93de8e525471e009c05e2b48e864f 100644 (file)
@@ -1396,104 +1396,67 @@ function get_sub_department($value)
  * Example:
  * \code
  * # Determine LDAP base where systems are stored
- * $base = get_ou('systemRDN') . $this->config->current['BASE'];
+ * $base = get_ou("core", "userRDN")  . $this->config->current['BASE'];
  * $ldap->cd($base);
  * \endcode
  * */
-function get_ou($name)
+function get_ou($class,$name)
 {
-  global $config;
+    global $config;
 
-  $map = array( 
-                "roleRDN"      => "ou=roles,",
-                "ogroupRDN"      => "ou=groups,",
-                "applicationRDN" => "ou=apps,",
-                "systemRDN"     => "ou=systems,",
-                "serverRDN"      => "ou=servers,ou=systems,",
-                "terminalRDN"    => "ou=terminals,ou=systems,",
-                "workstationRDN" => "ou=workstations,ou=systems,",
-                "printerRDN"     => "ou=printers,ou=systems,",
-                "phoneRDN"       => "ou=phones,ou=systems,",
-                "componentRDN"   => "ou=netdevices,ou=systems,",
-                "sambaMachineAccountRDN"   => "ou=winstation,",
-
-                "faxBlocklistRDN"   => "ou=gofax,ou=systems,",
-                "systemIncomingRDN"    => "ou=incoming,",
-                "aclRoleRDN"     => "ou=aclroles,",
-                "phoneMacroRDN"       => "ou=macros,ou=asterisk,ou=configs,ou=systems,",
-                "phoneConferenceRDN"  => "ou=conferences,ou=asterisk,ou=configs,ou=systems,",
-
-                "faiBaseRDN"         => "ou=fai,ou=configs,ou=systems,",
-                "faiScriptRDN"   => "ou=scripts,",
-                "faiHookRDN"     => "ou=hooks,",
-                "faiTemplateRDN" => "ou=templates,",
-                "faiVariableRDN" => "ou=variables,",
-                "faiProfileRDN"  => "ou=profiles,",
-                "faiPackageRDN"  => "ou=packages,",
-                "faiPartitionRDN"=> "ou=disk,",
-
-                "sudoRDN"       => "ou=sudoers,",
-
-                "deviceRDN"      => "ou=devices,",
-                "mimetypeRDN"    => "ou=mime,");
-
-  /* Preset ou... */
-  if ($config->get_cfg_value("core",$name, "_not_set_") != "_not_set_"){
-    $ou= $config->get_cfg_value("core",$name);
-  } elseif (isset($map[$name])) {
-    $ou = $map[$name];
-    return($ou);
-  } else {
-    trigger_error("No department mapping found for type ".$name);
-    return "";
-  }
-  if ($ou != ""){
-    if (!preg_match('/^[^=]+=[^=]+/', $ou)){
-      $ou = @LDAP::convert("ou=$ou");
-    } else {
-      $ou = @LDAP::convert("$ou");
+
+    // Check if RDN exists.
+    if(!$config->configRegistry->propertyExists($class, $name)){
+        trigger_error("No department mapping found for type ".$name);
+        return "";
     }
 
-    if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){
-      return($ou);
-    }else{
-      return("$ou,");
+    $ou = $config->get_cfg_value($class,$name);
+    if ($ou != ""){
+        if (!preg_match('/^[^=]+=[^=]+/', $ou)){
+            $ou = @LDAP::convert("ou=$ou");
+        } else {
+            $ou = @LDAP::convert("$ou");
+        }
+        if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){
+            return($ou);
+        }else{
+            return("$ou,");
+        }
+
+    } else {
+        return "";
     }
-  
-  } else {
-    return "";
-  }
 }
 
 
 /*! \brief Get the OU for users 
  *
- * Frontend for get_ou() with userRDN
+ * Frontend for get_ou("core", "userRDN")  with userRDN
  * */
 function get_people_ou()
 {
-  return (get_ou("userRDN"));
+  return (get_ou("core", "userRDN") );
 }
 
 
 /*! \brief Get the OU for groups
  *
- * Frontend for get_ou() with groupRDN
+ * Frontend for get_ou("core", "userRDN")  with groupRDN
  */
 function get_groups_ou()
 {
-  return (get_ou("groupRDN"));
+  return (get_ou("core", "userRDN") );
 }
 
 
 /*! \brief Get the OU for winstations
  *
- * Frontend for get_ou() with sambaMachineAccountRDN
+ * Frontend for get_ou("core", "userRDN")  with sambaMachineAccountRDN
  */
 function get_winstations_ou()
 {
-  return (get_ou("sambaMachineAccountRDN"));
+  return (get_ou("core", "userRDN") );
 }