Code

Added base detection button
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Feb 2007 06:15:56 +0000 (06:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Feb 2007 06:15:56 +0000 (06:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5710 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep4.inc
setup/setup_step4.tpl

index c923d7b120fd4209f938a5ebaaf6191caaf729d0..2f916100bd68146c2371e00a763c62416df91785 100644 (file)
@@ -38,7 +38,8 @@ class setup_step_4 extends setup_step
   var $crypt_methods  = array();
   var $mail_methods   = array();
 
-  var $connect_id =FALSE;
+  var $connect_id = FALSE;
+  var $bind_id    = FALSE;
 
   var $attributes = array("connection","location","admin","password","base","peopleou","peopledn","groupou",
                           "uidbase","encryption","mail","errors");
@@ -63,7 +64,6 @@ class setup_step_4 extends setup_step
 
     $smarty->assign("connection_established",$this->is_connection_established());
 
-
     $smarty->assign("peopledns",array("uid","cn"));
     $smarty->assign("crypt_methods",$this->crypt_methods);
     $smarty->assign("mail_methods",$this->mail_methods);
@@ -99,15 +99,31 @@ class setup_step_4 extends setup_step
   /* Check if specified server is reachable */
   function is_connection_established()
   {
-   if(!$this->connect_id= @ldap_connect(validate($this->connection))){
-      echo "false";
-      return FALSE;
-    }else{
-      echo "true";
-      return TRUE;
-    }
+
+    @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
+    $cid = @ldap_connect($this->connection);
+      
+    $ds = @ldap_bind($cid, $this->admin, $this->password);
+    @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
   }
 
+  
+  function try_to_get_base_automatically()
+  {
+
+    @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
+    $cid = @ldap_connect($this->connection);
+
+    $ds = @ldap_bind($cid);
+    @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+
+    $sr=   ldap_search ($ds, NULL, "objectClass=*", array("namingContexts"));
+    $attr= ldap_get_entries($cid,$sr); 
+    echo ldap_error($cid);
+    print_a($attr);
+  }
+
+
   function save_object()
   {
     foreach($this->attributes as $attr){
@@ -115,6 +131,11 @@ class setup_step_4 extends setup_step
         $this->$attr = $_POST[$attr];
       }
     }
+
+    /* Get base automatically */
+    if(isset($_POST['get_base'])){
+      $this->try_to_get_base_automatically();
+    }
   }
 }
 
index 3faa404c67270371c0b2bd8241ba43c17753b58e..2ad3175cbbd5f230e4197e2a0d84a8d3e3850ed4 100644 (file)
@@ -1,31 +1,28 @@
 <h2>{t}ldap connection{/t}</h2>
        <div class='step4_container'>
                <div class='step4_name'>
-                       <div style='vertical-align:middle;height:100%;'>{t}Connection url{/t}</div>
+                       {t}Location description{/t}
                </div>
                <div class='step4_value'>
-                       <input type='text' name='connection' maxlength='80' size='25' value='{$connection}'>
+                       <input type='text' name='location' maxlength='80' size='25' value='{$location}'>
                </div>
                <div class='step4_status'>
-                       {if !$connection_established}
-                               {t}Connection failed{/t}        
-                       {/if}
-                       <input type='submit' name='next' value='{t}Next{/t}'>
-               </div>
-               <div>
                </div>
        </div>
-
-{if $connection_established}
-
        <div class='step4_container'>
                <div class='step4_name'>
-                       {t}Location description{/t}
+                       <div style='vertical-align:middle;height:100%;'>{t}Connection url{/t}</div>
                </div>
                <div class='step4_value'>
-                       <input type='text' name='location' maxlength='80' size='25' value='{$location}'>
+                       <input type='text' name='connection' maxlength='80' size='25' value='{$connection}'>
                </div>
                <div class='step4_status'>
+                       {if !$connection_established}
+                               {t}Connection failed{/t}        
+                       {/if}
+                       <input type='submit' name='next' value='{t}Next{/t}'>
+               </div>
+               <div>
                </div>
        </div>
 
@@ -52,7 +49,6 @@
                        asd
                </div>
        </div>
-               
        <div class='step4_container'>
                <div class='step4_name'> 
                        {t}Base{/t}
                        <input type='text' name='base' maxlength='80' size='40' value='{$base}'>
                </div>
                <div class='step4_status'>
-                       asd
+                       <input type='submit' name='get_base' value="{t}Get base{/t}">
                </div>
        </div>
                
+
+{if $connection_established}
+
+               
        <div class='step4_container'>
                <div class='step4_name'> 
                        {t}People storage ou{/t}