Code

SETUP: Added ldap accessibility check to migration step
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Apr 2007 05:47:02 +0000 (05:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Apr 2007 05:47:02 +0000 (05:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6187 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep_Migrate.inc
setup/setup_migrate.tpl

index 60223b4b07367914143a50cfb7485a7c3365d877..8828f8d8bc93d62a0971c3c69a93fea7e67b8f94 100644 (file)
@@ -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();
+      }
+    }
   }
 }
 
index 26bbfeb88585edc2677fd48bedb0063c7e20525c..0c926e4aa23642fdef6ed6ed3be5861752f4c4d1 100644 (file)
@@ -1,6 +1,36 @@
 <div>
     <div class='default'>
-        <p><b>{t}Tasks{/t}</b></p>
+
+               {foreach from=$checks item=val key=key}
+       
+               <div class='step2_entry_name'><b>{$checks.$key.TITLE}</b></div>
+
+
+                               
+                       {if $checks.$key.STATUS}
+                               <div class='step2_successful'>{$checks.$key.STATUS_MSG}</div>
+                       {else}
+                               <div class='step2_failed'>{$checks.$key.STATUS_MSG}</div>
+                               {if $checks.$key.ERROR_MSG}
+                                       {$checks.$key.ERROR_MSG}
+                               {/if}
+                       {/if}
+                               <input type='submit' name='retry_{$key}' value='{t}Retry{/t}'>
+                       <p>&nbsp;</p>
+               {/foreach}
+
+
+       <p>&nbsp; </p>
+       <p>&nbsp; </p>
+       <p>&nbsp; </p>
+       <p> </p>
+       <p></p>
+       <p class='seperator'></p>
+       <p></p>
+       <p class='seperator'></p>
+
+
+
 
        * Create a test department with some objects to check for correct permissions
        <br>