From 2f99e65049f85b64c94e47350d08892c50921b84 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 12 Dec 2002 02:37:35 +0000 Subject: [PATCH] Slight changes to auth_user_login ... don't accept blank username/passwords and some minor logic changes --- auth/ldap/lib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/auth/ldap/lib.php b/auth/ldap/lib.php index d6a441d17e..04015eda69 100644 --- a/auth/ldap/lib.php +++ b/auth/ldap/lib.php @@ -12,6 +12,10 @@ function auth_user_login ($username, $password) { /// and false if they don't global $CFG; + + if (!$username or !$password) { // Don't allow blank usernames or passwords + return false; + } $ldap_connection = auth_ldap_connect(); @@ -21,20 +25,21 @@ function auth_user_login ($username, $password) { //if ldap_user_dn is empty, user does not exist if(!$ldap_user_dn){ + ldap_close($ldap_connection); return false; } // Try to bind with current username and password $ldap_login = @ldap_bind($ldap_connection, $ldap_user_dn, $password); + ldap_close($ldap_connection); if ($ldap_login) { - ldap_close($ldap_connection); return true; } } else { @ldap_close($ldap_connection); error("LDAP-module cannot connect to server: $CFG->ldap_host_url"); - return false ; } + return false; } -- 2.39.5