X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=gosa-core%2Fsetup%2Fclass_setupStep_Migrate.inc;h=f1074cbc812ff3c3f78f155002f5c1543dff520e;hb=9de00de8b48dec16637226552c5e8828e1f98a82;hp=5822d004dadd670179c033fd766d1402115ef316;hpb=a51f1c4daadf4d1c62c98e73a80f7de76155fa44;p=gosa.git diff --git a/gosa-core/setup/class_setupStep_Migrate.inc b/gosa-core/setup/class_setupStep_Migrate.inc index 5822d004d..f1074cbc8 100644 --- a/gosa-core/setup/class_setupStep_Migrate.inc +++ b/gosa-core/setup/class_setupStep_Migrate.inc @@ -113,6 +113,10 @@ class Step_Migrate extends setup_step var $acl_migrate_dialog = FALSE; var $migrate_acl_base_entry = ""; + /* Root object classes */ + var $rootOC_migrate_dialog = FALSE; + var $rootOC_details = array(); + function Step_Migrate() { $this->update_strings(); @@ -134,6 +138,12 @@ class Step_Migrate extends setup_step $this->checks['root']['ERROR_MSG'] = ""; $this->checkBase(); + $this->checks['rootOC']['TITLE'] = _("Checking object classes for root object"); + $this->checks['rootOC']['STATUS'] = FALSE; + $this->checks['rootOC']['STATUS_MSG']= ""; + $this->checks['rootOC']['ERROR_MSG'] = ""; + $this->checkBaseOC(); + $this->checks['permissions']['TITLE'] = _("Checking permissions on LDAP database"); $this->checks['permissions']['STATUS'] = FALSE; $this->checks['permissions']['STATUS_MSG']= ""; @@ -859,6 +869,7 @@ class Step_Migrate extends setup_step { /* Reset settings */ + $GOsa_26_found = FALSE; $this->migrate_users = array(); $this->acl_migrate_dialog = FALSE; $this->migrate_acl_base_entry = ""; @@ -874,7 +885,7 @@ class Step_Migrate extends setup_step $ldap = new ldapMultiplexer($ldap_l); $ldap->cd($cv['base']); $res = $ldap->cat($cv['base']); - + if(!$res){ $this->checks['acls']['STATUS'] = FALSE; $this->checks['acls']['STATUS_MSG']= _("LDAP query failed"); @@ -1014,7 +1025,7 @@ class Step_Migrate extends setup_step if($GOsa_25_found){ $str = ""; if(!empty($valid_groups)){ - $str.= "".sprintf(_("GOsa 2.5 adminitrative accounts found: %s."),trim($valid_groups,", "))."
"; + $str.= "".sprintf(_("GOsa 2.5 administrative accounts found: %s"),trim($valid_groups,", "))."
"; } $this->checks['acls']['STATUS'] = FALSE; $this->checks['acls']['STATUS_MSG']= _("Failed"); @@ -1508,7 +1519,35 @@ class Step_Migrate extends setup_step $this->initialize_checks(); } } - + + /************* + * Root object class check + *************/ + + if(isset($_POST['root_add_objectclasses'])){ + $this->rootOC_migrate_dialog = TRUE; + $this->dialog = TRUE; + } + if(isset($_POST['rootOC_dialog_cancel'])){ + $this->rootOC_migrate_dialog = FALSE; + $this->dialog = FALSE; + } + if(isset($_POST['rootOC_migrate_start'])){ + if($this->checkBaseOC(FALSE)){ + $this->checkBaseOC(); // Update overview info + $this->dialog = FALSE; + $this->rootOC_migrate_dialog = FALSE; + } + } + + + if($this->rootOC_migrate_dialog){ + $smarty = get_smarty(); + $smarty->assign("details",$this->rootOC_details); + $smarty->assign("method","rootOC_migrate_dialog"); + return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); + } + /************* * Administrative Account -- Migrate/Create *************/ @@ -1969,6 +2008,149 @@ class Step_Migrate extends setup_step } + /* Check if the root object includes the required object classes, e.g. gosaDepartment is required for ACLs. + * If the parameter just_check is true, then just check for the OCs. + * If the Parameter is false, try to add the required object classes. + */ + function checkBaseOC($just_check = TRUE) + { + /* Establish ldap connection */ + $cv = $this->parent->captured_values; + $ldap_l = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + + $ldap = new ldapMultiplexer($ldap_l); + + /* Check if root object exists */ + $ldap->cd($cv['base']); + $ldap->cat($cv['base']); + if(!$ldap->count()){ + $this->checks['rootOC']['STATUS'] = FALSE; + $this->checks['rootOC']['STATUS_MSG']= _("LDAP query failed"); + $this->checks['rootOC']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return; + } + + $attrs = $ldap->fetch(); + + /* Root object doesn't exists + */ + if(!in_array("gosaDepartment",$attrs['objectClass'])){ + if($just_check){ + + $this->rootOC_details = array(); + $mods = array(); + + /* Get list of possible container objects, to be able to detect naming + * attributes and missing attribute types. + */ + if(!class_available("departmentManagement")){ + $this->checks['rootOC']['STATUS'] = FALSE; + $this->checks['rootOC']['STATUS_MSG']= _("Failed"); + $this->checks['rootOC']['ERROR_MSG'] = sprintf(_("Missing GOsa class %s."),"departmentManagement"). + " "._("Please check your installation."); + return; + } + + /* Try to detect base class type, e.g. is it a dcObject. + */ + $dep_types = departmentManagement::get_support_departments(); + $dep_type =""; + foreach($dep_types as $dep_name => $dep_class){ + if(in_array($dep_class['CLASS'], $attrs['objectClass'])){ + $dep_type = $dep_name; + break; + } + } + + /* If no known base class was detect, abort with message + */ + if(empty($dep_type)){ + $this->checks['rootOC']['STATUS'] = FALSE; + $this->checks['rootOC']['STATUS_MSG']= _("Failed"); + $this->checks['rootOC']['ERROR_MSG'] = + sprintf(_("Could not detect the object type of your root object, please try to add the objectClass '%s' manually."),"gosaDepartment"); + return; + } + + /* Create 'current' and 'target' object properties, to be able to display + * a set of modifications required to create a valid GOsa department. + */ + $str = "dn: ".$cv['base']."\n"; + for($i = 0 ; $i<$attrs['objectClass']['count'];$i++){ + $str .= "objectClass: ".$attrs['objectClass'][$i]."\n"; + } + $this->rootOC_details['current'] = $str; + + /* Create target infos + */ + $str = "dn: ".$cv['base']."\n"; + for($i = 0 ; $i<$attrs['objectClass']['count'];$i++){ + $str .= "objectClass: ".$attrs['objectClass'][$i]."\n"; + $mods['objectClass'][] = $attrs['objectClass'][$i]; + } + $mods['objectClass'][] = "gosaDepartment"; + $str .= "objectClass: gosaDepartment\n"; + + /* Append attribute 'ou', it is required by gosaDepartment + */ + if(!isset($attrs['ou'])){ + $val = "GOsa"; + if(isset($attrs[$dep_types[$dep_type]['ATTR']][0])){ + $val = $attrs[$dep_types[$dep_type]['ATTR']][0]; + } + $str .= "ou: ".$val."\n"; + $mods['ou'] =$val; + } + + /*Append description, it is required by gosaDepartment too. + */ + if(!isset($attrs['description'])){ + $val = "GOsa"; + if(isset($attrs[$dep_types[$dep_type]['ATTR']][0])){ + $val = $attrs[$dep_types[$dep_type]['ATTR']][0]; + } + $str .= "description: ".$val."\n"; + $mods['description'] = $val; + } + $this->rootOC_details['target'] = $str; + $this->rootOC_details['mods'] = $mods; + + /* Add button that allows to open the migration details + */ + $this->checks['rootOC']['STATUS'] = FALSE; + $this->checks['rootOC']['STATUS_MSG']= _("Failed"); + $this->checks['rootOC']['ERROR_MSG'] = " "; + + return(FALSE); + }else{ + + /* Add root object */ + $ldap->cd($cv['base']); + if(isset($this->rootOC_details['mods'])){ + $res = $ldap->modify($this->rootOC_details['mods']); + if(!$res){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $source, LDAP_MOD, get_class())); + } + return($res); + }else{ + trigger_error("No modifications to make... "); + } + } + return(TRUE); + } + + /* Create & remove of dummy object was successful */ + $this->checks['rootOC']['STATUS'] = TRUE; + $this->checks['rootOC']['STATUS_MSG']= _("Ok"); + $this->checks['rootOC']['ERROR_MSG'] = ""; + } + + /* Return ldif information for a * given attribute array */