Code

Added config viewer plugin
[gosa.git] / gosa-core / setup / class_setupStep_Ldap.inc
index 9b5f670eafdfbaf412ef674874fdbb70b750eff5..eca54c38a809806ade702a4075aba2d716336055 100644 (file)
@@ -40,7 +40,7 @@ class Step_Ldap extends setup_step
   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";
+  var $header_image= "images/setup/ldap.png";
 
   function Step_Ldap()
   {
@@ -60,7 +60,7 @@ class Step_Ldap extends setup_step
   {
     $smarty = get_smarty();
     foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
+      $smarty->assign($attr,htmlentities($this->$attr,ENT_QUOTES,"UTF-8"));
     }
 
     /* Assign connection status */
@@ -96,23 +96,30 @@ 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 failed on server '%s'."),$this->connection); 
+      $str = sprintf(_("Anonymous bind to server '%s' failed!"),$this->connection); 
       if(!empty($this->admin)){
-        $str = sprintf(_("Bind as user '%s' failed on server '%s'."),$this->admin,$this->connection);
+        $str = sprintf(_("Bind as user '%s' failed!"),$this->admin,$this->connection);
       }      
       return("<font color='red'>".$str."</font>");
     }else{
       if(empty($this->admin)){
-        $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>");
+        $str = sprintf(_("Anonymous bind to 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' on server '%s' succeeded."),$this->admin,$this->connection);
+        $str = sprintf(_("Bind as user '%s' to server '%s' succeeded!"),$this->admin,$this->connection);
         return("<font color='green'>".$str."</font>");
       }      
     }
@@ -122,12 +129,16 @@ class Step_Ldap extends setup_step
   function resolve_user()
   {
     $filter  = $this->resolve_filter;
-    $ldap = new LDAP("","",$this->connection);
+
+    /* Establish ldap connection */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP("","",$this->connection, FALSE, $this->tls);
+    $ldap = new ldapMultiplexer($ldap_l);
     $ldap->cd($this->base);
     $ldap->search("(&(objectClass=person)(|(uid=".$filter.")(cn=".$filter.")))");
     $tmp = array();
     while($attrs = $ldap->fetch()){
-      $tmp[base64_encode($attrs['dn'])]= @LDAP::fix($attrs['dn']);
+      $tmp[base64_encode($attrs['dn'])]= LDAP::fix($attrs['dn']);
       natcasesort($tmp);
     }
     return($tmp);