[PATCH] Bug Fixing Auth_with_LDAP

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Wed Sep 16 04:57:24 NZST 2009


---
 C4/Auth_with_ldap.pm |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm
index 08a4353..2fb0eea 100644
--- a/C4/Auth_with_ldap.pm
+++ b/C4/Auth_with_ldap.pm
@@ -55,7 +55,7 @@ my $prefhost  = $ldap->{hostname}	or die ldapserver_error('hostname');
 my $base      = $ldap->{base}		or die ldapserver_error('base');
 $ldapname     = $ldap->{user}		;
 $ldappassword = $ldap->{pass}		;
-our %mapping  = %{$ldap->{mapping}} || (); #	or die ldapserver_error('mapping');
+our %mapping  = ($ldap->{mapping}?%{$ldap->{mapping}}:()); #	or die ldapserver_error('mapping');
 my @mapkeys = keys %mapping;
 $debug and print STDERR "Got ", scalar(@mapkeys), " ldap mapkeys (  total  ): ", join ' ', @mapkeys, "\n";
 @mapkeys = grep {defined $mapping{$_}->{is}} @mapkeys;
@@ -119,9 +119,10 @@ sub checkpw_ldap {
             $debug and warn "LDAP bind failed as kohauser $principal_name: ". description($res);
             return 0;
         }
-	} else {
-        my $search = search_method($db, $userid) or return 0;   # warnings are in the sub
-        $userldapentry = $search->shift_entry;
+	}
+    my $search = search_method($db, $userid) or return 0;   # warnings are in the sub
+    $userldapentry = $search->shift_entry;
+	if (!$ldap->{auth_by_bind}) {
 		my $cmpmesg = $db->compare( $userldapentry, attr=>'userpassword', value => $password );
 		if ($cmpmesg->code != 6) {
 			warn "LDAP Auth rejected : invalid password for user '$userid'. " . description($cmpmesg);
-- 
1.6.0.4


--------------010908090409050604070906--


More information about the Koha mailing list