From 48029b82c110fa8a93cb3476982dc19b92195a04 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 27 Apr 2007 07:43:40 +0000 Subject: [PATCH] Updated checks. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6198 594d385d-05f5-0310-b6e9-bd551577e9d8 --- setup/class_setupStep_Migrate.inc | 97 +++++++++++++------------------ setup/setup_migrate.tpl | 5 ++ 2 files changed, 45 insertions(+), 57 deletions(-) diff --git a/setup/class_setupStep_Migrate.inc b/setup/class_setupStep_Migrate.inc index aee8992d2..5fd72d01d 100644 --- a/setup/class_setupStep_Migrate.inc +++ b/setup/class_setupStep_Migrate.inc @@ -42,10 +42,12 @@ class Step_Migrate extends setup_step var $acl_create_changes = ""; // Contains ldif information about changes var $acl_create_confirmed= FALSE; + /* Checks initialised ? */ + var $checks_initialised = FALSE; + function Step_Migrate() { $this->update_strings(); - $this->initialize_checks(); } function update_strings() @@ -104,19 +106,20 @@ class Step_Migrate extends setup_step /* Search for gosaAcls */ $ldap->cd($cv['base']); - $ldap->search("(&(objectClass=gosaAccount)(|(objectClass=posixAccount)(objectClass=inetOrgPerson)(objectClass=organizationalPerson)))"); - - if($ldap->count() ==0){ + $res = $ldap->search("(&(objectClass=gosaAccount)(|(objectClass=posixAccount)". + "(objectClass=inetOrgPerson)(objectClass=organizationalPerson)))"); + if(!$res){ + $this->checks['acls']['STATUS'] = FALSE; + $this->checks['acls']['STATUS_MSG']= _("Ldap query failed."); + $this->checks['acls']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + }elseif($ldap->count() == 0){ $this->checks['acls']['STATUS'] = TRUE; $this->checks['acls']['STATUS_MSG']= _("Ok"); - $this->checks['acls']['ERROR_MSG'] = ""; }else{ $this->checks['acls']['STATUS'] = FALSE; $this->checks['acls']['STATUS_MSG']= _("Failed"); - $this->checks['acls']['ERROR_MSG'] = ""; $this->checks['acls']['ERROR_MSG'].= ""; } - return($ldap->count()>=1); } @@ -145,6 +148,16 @@ class Step_Migrate extends setup_step $testEntry['description']= "Created by GOsa setup, this object can be removed."; $testEntry['ou'] = $name; + /* check if simple ldap cat will be successful + */ + $res = $ldap->cat($cv['base']); + if(!$res){ + $this->checks['permissions']['STATUS'] = FALSE; + $this->checks['permissions']['STATUS_MSG']= _("Ldap query failed."); + $this->checks['permissions']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + return(false); + } + /* Try to create dummy object */ $ldap->cd ($dn); @@ -156,8 +169,6 @@ class Step_Migrate extends setup_step $this->checks['permissions']['STATUS_MSG']= _("Failed"); $this->checks['permissions']['ERROR_MSG'] = sprintf(_("The specified user '%s' does not have full access to your ldap database."),$cv['admin']); - $this->checks['permissions']['ERROR_MSG'].= - ""; return(false); } @@ -170,15 +181,13 @@ class Step_Migrate extends setup_step $this->checks['permissions']['STATUS_MSG']= _("Failed"); $this->checks['permissions']['ERROR_MSG'] = sprintf(_("The specified user '%s' does not have full access to your ldap database."),$cv['admin']); - $this->checks['permissions']['ERROR_MSG'].= - ""; return(false); } /* Create & remove of dummy object was successful */ $this->checks['permissions']['STATUS'] = TRUE; $this->checks['permissions']['STATUS_MSG']= _("Ok"); - $this->checks['permissions']['ERROR_MSG'] = ""; + $this->checks['permissions']['ERROR_MSG'] = ""; return(true); } @@ -208,7 +217,7 @@ class Step_Migrate extends setup_step /* Get all invisible users */ $ldap->cd($cv['base']); - $ldap->search("(&(|(objectClass=posixAccount)(objectClass=inetOrgPerson)(objectClass=organizationalPerson))(!(objectClass=gosaAccount)))",array("sn","givenName","cn","uid")); + $res =$ldap->search("(&(|(objectClass=posixAccount)(objectClass=inetOrgPerson)(objectClass=organizationalPerson))(!(objectClass=gosaAccount)))",array("sn","givenName","cn","uid")); while($attrs = $ldap->fetch()){ if(!preg_match("/,dc=addressbook,/",$attrs['dn'])){ $attrs['checked'] = FALSE; @@ -224,18 +233,20 @@ class Step_Migrate extends setup_step } /* No invisible */ - if(count($this->users_to_migrate) == 0){ + if(!$res){ + $this->checks['users_visible']['STATUS'] = FALSE; + $this->checks['users_visible']['STATUS_MSG']= _("Ldap query failed."); + $this->checks['users_visible']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + }elseif(count($this->users_to_migrate) == 0){ $this->checks['users_visible']['STATUS'] = TRUE; $this->checks['users_visible']['STATUS_MSG']= _("Ok"); $this->checks['users_visible']['ERROR_MSG'] = ""; - $this->checks['users_visible']['ERROR_MSG'] .= ""; }else{ $this->checks['users_visible']['STATUS'] = FALSE; $this->checks['users_visible']['STATUS_MSG']= ""; $this->checks['users_visible']['ERROR_MSG'] = sprintf(_("Found %s users that will not be visible in GOsa."), count($this->users_to_migrate)); $this->checks['users_visible']['ERROR_MSG'] .= ""; - $this->checks['users_visible']['ERROR_MSG'] .= ""; } } @@ -318,7 +329,7 @@ class Step_Migrate extends setup_step /* Get all invisible departments */ $ldap->cd($cv['base']); - $ldap->search("(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))",array("ou","description","dn")); + $res = $ldap->search("(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))",array("ou","description","dn")); while($attrs = $ldap->fetch()){ $attrs['checked'] = FALSE; $attrs['before'] = ""; @@ -350,17 +361,19 @@ class Step_Migrate extends setup_step /* If we have no invisible departments found * tell the user that everything is ok */ - if(count($this->deps_to_migrate) == 0){ + if(!$res){ + $this->checks['deps_visible']['STATUS'] = FALSE; + $this->checks['deps_visible']['STATUS_MSG']= _("Ldap query failed."); + $this->checks['deps_visible']['ERROR_MSG'] = _("Possibly the 'root object' is missing."); + }elseif(count($this->deps_to_migrate) == 0 ){ $this->checks['deps_visible']['STATUS'] = TRUE; $this->checks['deps_visible']['STATUS_MSG']= _("Ok"); $this->checks['deps_visible']['ERROR_MSG'] = ""; - $this->checks['deps_visible']['ERROR_MSG'] .= ""; }else{ $this->checks['deps_visible']['STATUS'] = FALSE; $this->checks['deps_visible']['STATUS_MSG']= "";//sprintf(_("%s entries found"),count($this->deps_to_migrate)); $this->checks['deps_visible']['ERROR_MSG'] = sprintf(_("Found %s departments that will not be visible in GOsa."),count($this->deps_to_migrate)); $this->checks['deps_visible']['ERROR_MSG'] .= ""; - $this->checks['deps_visible']['ERROR_MSG'] .= ""; } } @@ -529,6 +542,12 @@ class Step_Migrate extends setup_step function execute() { + /* Initialise checks if this is the first call */ + if(!$this->checks_initialised || isset($_POST['reload'])){ + $this->initialize_checks(); + $this->checks_initialised = TRUE; + } + /* Permission check */ $this->check_ldap_permissions(); @@ -536,10 +555,6 @@ class Step_Migrate extends setup_step * Root object check *************/ - if(isset($_POST['retry_root'])) { - $this->checkBase(); - } - if(isset($_POST['retry_root_create'])){ $this->checkBase(FALSE); } @@ -743,44 +758,13 @@ class Step_Migrate extends setup_step if($just_check){ $this->checks['root']['STATUS'] = FALSE; $this->checks['root']['STATUS_MSG']= _("Failed"); - $this->checks['root']['ERROR_MSG'] = ""; $this->checks['root']['ERROR_MSG'].= ""; return(FALSE); }else{ - /* Try to find out which values are necessary */ - $tmp = $ldap->get_objectclasses(); - $oc = $tmp['organization']; - $must_attrs = array(); - if(preg_match("/MUST/",$oc)){ - $must = preg_replace("/^.* MUST/","",$oc); - $must = preg_replace("/MAY.*$/","",$must); - $must = trim(preg_replace("/[\(\)\$]/","",$must)); - $must_attrs = split(" ",$must); - foreach($must_attrs as $key => $attrs){ - if(empty($attrs)){ - unset($must_attrs[$key]); - } - } - } - - /* Root object does not exists try to create it */ - $ldapadd["objectclass"][0]="top"; - $ldapadd["objectclass"][1]="organization"; - - /* Try to fill all collected must attributes */ - $base_parts = preg_split("/,/",$cv['base']); - foreach($must_attrs as $attr){ - foreach($base_parts as $part){ - if(preg_match("/^".$attr."=/",$part) && !isset($ldapadd[$attr])){ - $ldapadd[$attr]= preg_replace("/^[^=]*+=/","",$part); - } - } - } - /* Add root object */ $ldap->cd($cv['base']); - $res = $ldap->add($ldapadd); + $res = $ldap->create_missing_trees($cv['base']); /* If adding failed, tell the user */ if(!$res){ @@ -796,7 +780,6 @@ class Step_Migrate extends setup_step /* Create & remove of dummy object was successful */ $this->checks['root']['STATUS'] = TRUE; $this->checks['root']['STATUS_MSG']= _("Ok"); - $this->checks['root']['ERROR_MSG'] = ""; } diff --git a/setup/setup_migrate.tpl b/setup/setup_migrate.tpl index d0f6f8c8b..30ac7d651 100644 --- a/setup/setup_migrate.tpl +++ b/setup/setup_migrate.tpl @@ -2,6 +2,11 @@

Style fixes necessary here ;-)

+

+ Create a reload for each entry later + +

+
{if $method == "default"} -- 2.30.2