From: hickert Date: Wed, 25 Apr 2007 05:47:02 +0000 (+0000) Subject: SETUP: Added ldap accessibility check to migration step X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4ea859bfca37b13ac8c334d8a6ba3e2fad019bf3;p=gosa.git SETUP: Added ldap accessibility check to migration step git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6187 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/setup/class_setupStep_Migrate.inc b/setup/class_setupStep_Migrate.inc index 60223b4b0..8828f8d8b 100644 --- a/setup/class_setupStep_Migrate.inc +++ b/setup/class_setupStep_Migrate.inc @@ -25,10 +25,12 @@ class Step_Migrate extends setup_step var $languages = array(); var $attributes = array(); var $header_image = "images/monitoring.png"; + var $checks = array(); function Step_Migrate() { $this->update_strings(); + $this->initialize_checks(); } function update_strings() @@ -37,16 +39,92 @@ class Step_Migrate extends setup_step $this->s_title_long = _("LDAP inspection"); $this->s_info = _("Analyze your current LDAP for GOsa compatibility"); } - + + function initialize_checks() + { + $this->checks = array(); + $this->checks['permissions']['TITLE'] = _("Checking permissions on ldap database"); + $this->checks['permissions']['STATUS'] = FALSE; + $this->checks['permissions']['STATUS_MSG']= ""; + $this->checks['permissions']['CHK_FUNC'] = "check_ldap_permissions"; + $this->checks['permissions']['ERROR_MSG'] = _("The specified user '%s' does not have full access to your ldap database."); + } + + + /* Check ldap accessibility + * Create and remove a dummy object, + * to ensure that we have the necessary permissions + */ + function check_ldap_permissions() + { + $cv = $this->parent->captured_values; + $ldap = new LDAP($cv['admin'], + $cv['password'], + $cv['connection'], + FALSE, + $cv['tls']); + $name = "GOsa_setup_text_entry_".session_id().rand(0,999999); + $dn = "ou=".$name.",".$cv['base']; + $testEntry= array(); + $testEntry['objectClass'][]= "top"; + $testEntry['objectClass'][]= "organizationalUnit"; + $testEntry['objectClass'][]= "gosaDepartment"; + $testEntry['description']= "Created by GOsa setup, this object can be removed."; + $testEntry['ou'] = $name; + + $ldap->cd ($dn); + $res = $ldap->add($testEntry); + if(!$res){ + $this->checks['permissions']['STATUS'] = FALSE; + $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']); + return(false); + } + + $res = $ldap->rmDir($dn); + if(!$res){ + $this->checks['permissions']['STATUS'] = FALSE; + $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']); + return(false); + } + + $this->checks['permissions']['STATUS'] = TRUE; + $this->checks['permissions']['STATUS_MSG']= _("Ok"); + $this->checks['permissions']['ERROR_MSG'] = ""; + return(true); + } + + + function check_visible_organizationalUnits() + { + + } + + function execute() { $smarty = get_smarty(); + $smarty->assign("checks",$this->checks); return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__)))); } function save_object() { $this->is_completed = TRUE; + + $once = TRUE; + foreach($_POST as $name => $value){ + + if(preg_match("/^retry_/",$name) && $once){ + $once = FALSE; + $check = preg_replace("/^retry_/","",$name); + $func = $this->checks[$check]['CHK_FUNC']; + $this->checks[$check]['STATUS']=$this->$func(); + } + } } } diff --git a/setup/setup_migrate.tpl b/setup/setup_migrate.tpl index 26bbfeb88..0c926e4aa 100644 --- a/setup/setup_migrate.tpl +++ b/setup/setup_migrate.tpl @@ -1,6 +1,36 @@
-

{t}Tasks{/t}

+ + {foreach from=$checks item=val key=key} + +
{$checks.$key.TITLE}
+ + + + {if $checks.$key.STATUS} +
{$checks.$key.STATUS_MSG}
+ {else} +
{$checks.$key.STATUS_MSG}
+ {if $checks.$key.ERROR_MSG} + {$checks.$key.ERROR_MSG} + {/if} + {/if} + +

 

+ {/foreach} + + +

 

+

 

+

 

+

+

+

+

+

+ + + * Create a test department with some objects to check for correct permissions