Code

Updated in
[gosa.git] / gosa-core / setup / class_setupStep_Ldap.inc
index 03525da833329b87746a20781aef3dcd88181401..d6cea388deba9f8186cdde96eca4bc7515a27248 100644 (file)
@@ -96,10 +96,17 @@ class Step_Ldap extends setup_step
     $this->bind_id    = FALSE;
 
     @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
-    $this->connect_id = @ldap_connect($this->connection);
+    $this->connect_id = ldap_connect($this->connection);
       
-    @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3);
-    $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password);
+    if($this->tls){
+      if(@ldap_set_option($this->connect_id, LDAP_OPT_REFERRALS, 0))
+        if(@ldap_start_tls($this->connect_id))
+          $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password);
+      @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3);
+    }else{
+      @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3);
+      $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password);
+    }
     
     if(!$this->bind_id){
       $str = sprintf(_("Anonymous bind to server '%s' failed!"),$this->connection); 
@@ -143,7 +150,7 @@ class Step_Ldap extends setup_step
     $reset = FALSE;
     foreach($this->attributes as $attr){
       if(isset($_POST[$attr])){
-        if(in_array($attr,array("base","connection")) && $this->$attr != get_post($attr)){
+        if(in_array_strict($attr,array("base","connection")) && $this->$attr != get_post($attr)){
           $reset = TRUE;
         }
         $this->$attr = get_post($attr);
@@ -153,7 +160,7 @@ class Step_Ldap extends setup_step
     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(is_array($attr) && !in_array_strict(get_post("base"),$attr)){
         if(isset($attr[0])){
           $this->base = $attr[0];
         }