From: hickert Date: Mon, 10 May 2010 13:32:34 +0000 (+0000) Subject: Updated get_ou it receives values from the config registry now. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a4f6ad85a3ab618b6aa826e5021b6bd183914537;p=gosa.git Updated get_ou it receives values from the config registry now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18262 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_CopyPasteHandler.inc b/gosa-core/include/class_CopyPasteHandler.inc index 5d8330841..586f3b11e 100644 --- a/gosa-core/include/class_CopyPasteHandler.inc +++ b/gosa-core/include/class_CopyPasteHandler.inc @@ -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){ diff --git a/gosa-core/include/class_config.inc b/gosa-core/include/class_config.inc index e50de7e22..97c032ce3 100644 --- a/gosa-core/include/class_config.inc +++ b/gosa-core/include/class_config.inc @@ -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){ diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 1b45db134..6e7ec7c85 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -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){ diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index e7637663a..23badf712 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -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") ); }