Bug 8148: Prevent local authentification fallback if an invalid LDAP password was...
authorFrédérick <frederick.capovilla@libeo.com>
Wed, 19 Feb 2014 16:55:35 +0000 (11:55 -0500)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 7 Aug 2014 19:22:21 +0000 (16:22 -0300)
http://bugs.koha-community.org/show_bug.cgi?id=8148
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Dobrica Pavlinusic <dpavlin@rot13.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

C4/Auth.pm
C4/Auth_with_ldap.pm

index ad6d99b..c2faf8d 100644 (file)
@@ -1543,6 +1543,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);
     }
 
index 6000e76..4f47f66 100644 (file)
@@ -88,7 +88,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);
@@ -163,7 +165,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;
                }
        }