From c085739f9ba55a51a132befac94efc35b5995d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= Date: Wed, 19 Feb 2014 11:55:35 -0500 Subject: [PATCH] Prevent local authentification fallback if an invalid LDAP password was entered. --- C4/Auth.pm | 1 + C4/Auth_with_ldap.pm | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 00eeeef..228d6fd 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1506,6 +1506,7 @@ sub checkpw { if ($ldap) { $debug and print STDERR "## checkpw - checking LDAP\n"; my ($retval,$retcard,$retuserid) = checkpw_ldap(@_); # EXTERNAL AUTH + return 0 if $retval == -1; ($retval) and return ($retval,$retcard,$retuserid); } diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index 3b40015..e6674ea 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -87,7 +87,9 @@ sub search_method { base => $base, filter => $filter, # attrs => ['*'], - ) or die "LDAP search failed to return object."; + ); + die "LDAP search failed to return object : " . $search->error if $search->code; + my $count = $search->count; if ($search->code > 0) { warn sprintf("LDAP Auth rejected : %s gets %d hits\n", $filter->as_string, $count) . description($search); @@ -162,7 +164,7 @@ sub checkpw_ldap { my $cmpmesg = $db->compare( $userldapentry, attr=>'userpassword', value => $password ); if ($cmpmesg->code != 6) { warn "LDAP Auth rejected : invalid password for user '$userid'. " . description($cmpmesg); - return 0; + return -1; } } -- 1.7.2.5