diff --git a/inc/auth/ldap.class.php b/inc/auth/ldap.class.php
index 852634e3d182a8925143d6c80769de12f3c37d0c..f3060637960c3f50e30824bf61801a3e96872d91 100644
--- a/inc/auth/ldap.class.php
+++ b/inc/auth/ldap.class.php
@@ -273,8 +273,8 @@ class auth_ldap extends auth_basic {
     function _openLDAP(){
         if($this->con) return true; // connection already established
 
-        if(!$this->cnf['port']) $port = 636;
-        $this->con = @ldap_connect($this->cnf['server'],$this->cnf['port']);
+        $port = ($this->cnf['port']) ? $this->cnf['port'] : 636;
+        $this->con = @ldap_connect($this->cnf['server'],$port);
         if(!$this->con){
             msg("LDAP: couldn't connect to LDAP server",-1);
             return false;