From 160ad7e86603f36a27f635eedc2d99bbef77003d Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 7 Aug 2017 09:21:26 +0200 Subject: [PATCH] Fixed Connection failure in ldap --- pandora_console/include/auth/mysql.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index a7e710dcb2..91c783d10b 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -645,15 +645,26 @@ function ldap_process_user_login ($login, $password) { } } - $ldap_login_attr = isset($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) . "=" : ''; - $ldap_base_dn = isset($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; + $ldap_login_attr = !empty($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) . "=" : ''; + $ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; - if (strlen($password) == 0 || + if(!empty($ldap_base_dn)){ + if (strlen($password) == 0 || + !@ldap_bind($ds, $ldap_login_attr.io_safe_output($login).$ldap_base_dn, $password) ) { + html_debug("entra1",true); + $config["auth_error"] = 'User not found in database or incorrect password'; + @ldap_close ($ds); + + return false; + } + } else { + if (strlen($password) == 0 || !@ldap_bind($ds, io_safe_output($login), $password) ) { - $config["auth_error"] = 'User not found in database or incorrect password'; - @ldap_close ($ds); - - return false; + $config["auth_error"] = 'User not found in database or incorrect password'; + @ldap_close ($ds); + + return false; + } } @ldap_close ($ds);