From 4bd88fdfa494ab670dc1288aee27cf877d80ac41 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Fri, 31 May 2013 10:17:08 +0200 Subject: [PATCH] Bug 10384 - Software error when LDAP connexion fails When using LDAP authentication, the authentication falls back to normal authentication if user does not exist in LDAP. Actually, if the LDAP server is down, you get a software error (even with mysql user) : Can't call method "bind" on an undefined value at C4/Auth_with_ldap.pm line 134, line 558. This patch catches this error to allow normal authentication when LDAP connexion fails. Test plan : - Configure LDAP connexion with a host not having LDAP. ie : 1 localhost dc=test,dc=com cn=Manager,dc=test,dc=com passwd 0 0 0 MAIN PT - Try to connect with mysql user (defined in koha-conf.xml) - Try to connect with a user defined in borrowers You may try to connect with working LDAP connexion Signed-off-by: Chris Cormack --- C4/Auth_with_ldap.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index 1f2f617..6143c9f 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -103,6 +103,11 @@ sub checkpw_ldap { my ($dbh, $userid, $password) = @_; my @hosts = split(',', $prefhost); my $db = Net::LDAP->new(\@hosts); + unless ( $db ) { + warn "LDAP connexion failed"; + return 0; + } + #$debug and $db->debug(5); my $userldapentry; -- 1.7.10.4