From e29a98f8166df4cad0cb6ea12bd06a39e52a4d47 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Fri, 31 May 2013 10:17:08 +0200 Subject: [PATCH] Bug 10384: fall back to normal authentication if LDAP server is not available This fixes a bug where, assuming LDAP authentication is enabled, if a user tries to log in while the LDAP server is down, the following fatal error is displayed: 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 Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton (cherry picked from commit 96ac578960cb4f2c5a964b3ac7fa4f9ba676b95d) Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 85130dafc515363eba8f44973291a7af893a8b52) Signed-off-by: Bernardo Gonzalez Kriegel (cherry picked from commit 85130dafc515363eba8f44973291a7af893a8b52) --- 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 f3c1f7f39d..9b0f594297 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; if ( $ldap->{auth_by_bind} ) { -- 2.39.5