Code

Updated implicit_flush detection, it should be turned off not on
[gosa.git] / setup / class_setupStep_Ldap.inc
index dc0b9898ce2deb71271a5938b6c6165340bff9a9..b2c467ef646c48fa7c29bb9057e78ad79382c149 100644 (file)
@@ -27,6 +27,8 @@ class Step_Ldap extends setup_step
   var $admin      = "";
   var $password   = "";
   var $base       = "";
+  var $append_base_to_admin_dn = FALSE;
+  var $admin_given = "";
 
   var $connect_id = FALSE;
   var $bind_id    = FALSE;
@@ -35,9 +37,10 @@ class Step_Ldap extends setup_step
   var $resolve_user   = FALSE;
   var $tls            = FALSE;
 
-  var $attributes = array("connection","location","admin","password","base","tls");
-  var $header_image= "images/proxy.png";
+  var $rfc2307bis             = FALSE;
+  var $attributes = array("connection","location","admin","password","base","admin_given","append_base_to_admin_dn","tls","rfc2307bis");
 
+  var $header_image= "images/proxy.png";
 
   function Step_Ldap()
   {
@@ -100,10 +103,10 @@ class Step_Ldap extends setup_step
       return("<font color='red'>".$str."</font>");
     }else{
       if(empty($this->admin)){
-        $str = sprintf(_("Anonymous bind successful on server '%s'. Please specify user and password."),$this->connection); 
-        return("<font color='blue'>".$str."</font>");
+        $str = sprintf(_("Anonymous bind on server '%s' succeeded."), $this->connection);
+        return("<font color='blue'>".$str."</font> <font color='red'>"._("Please specify user and password.")."</font>");
       }else{
-        $str = sprintf(_("Bind as user '%s' successful on server '%s'."),$this->admin,$this->connection);
+        $str = sprintf(_("Bind as user '%s' on server '%s' succeeded."),$this->admin,$this->connection);
         return("<font color='green'>".$str."</font>");
       }      
     }
@@ -127,9 +130,23 @@ class Step_Ldap extends setup_step
 
   function save_object()
   {
+    $reset = FALSE;
     foreach($this->attributes as $attr){
       if(isset($_POST[$attr])){
-        $this->$attr = $_POST[$attr];
+        if(in_array($attr,array("base","connection")) && $this->$attr != get_post($attr)){
+          $reset = TRUE;
+        }
+        $this->$attr = get_post($attr);
+      }
+    }
+
+    if($reset){
+      $this->parent->disable_steps_from(($this->parent->step_name_to_id(get_class($this))) +1);
+      $attr = @LDAP::get_naming_contexts($this->connection);
+      if(is_array($attr) && !in_array(get_post("base"),$attr)){
+        if(isset($attr[0])){
+          $this->base = $attr[0];
+        }
       }
     }
 
@@ -144,23 +161,40 @@ class Step_Ldap extends setup_step
     $this->dialog = $this->resolve_user;
  
     if(isset($_POST['resolve_filter'])){
-      $this->resolve_filter = $_POST['resolve_filter'];
+      $this->resolve_filter = get_post('resolve_filter');
     }
 
     if(isset($_POST['use_selected_user'])){
 
       if(isset($_POST['admin_to_use'])){
-        $this->admin = base64_decode($_POST['admin_to_use']);
+        $this->admin = base64_decode(get_post('admin_to_use'));
         $this->resolve_user = false;
       }
     }
 
+    if(isset($_POST['append_base_to_admin_dn'])){
+      $this->append_base_to_admin_dn = TRUE;
+    }else{
+      $this->append_base_to_admin_dn = FALSE;
+    }
+    if($this->append_base_to_admin_dn){
+      $base = $this->base;      
+      if(!preg_match("/,$/",$this->admin_given)){
+        $base = ",".$base;
+      }
+      $this->admin = $this->admin_given.$base;
+    }else{
+      $this->admin = $this->admin_given;
+    }
+
     $this->get_connection_status();
-    if($this->bind_id){
+    if($this->bind_id && !empty($this->admin) && !empty($this->base)){
       $this->is_completed =TRUE;
     }else{
       $this->is_completed =FALSE;
     }
+
   }
 }