From 4f33e1bdd2ccf5c44e8b6aa8501319f62d2d81da Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 29 Aug 2014 13:37:07 +0200 Subject: [PATCH] Bug 12831 - local only logins should work with LDAP This fixes regression introducted in Bug 8148. If ldap is enabled, and using auth_by_bind, one will not be able to login using any local accounts which do not appear in the ldap directory. This is problematic because a number of koha system accounts are unlikely to have a parallel in the active directory.. for instance SIP Service User accounts. Signed-off-by: Chris Cormack Seems to work as advertised, there may be other error codes we need to trap, but this is a good start --- C4/Auth_with_ldap.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index b42506d..c313af9 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -146,7 +146,11 @@ sub checkpw_ldap { my $res = $db->bind( $principal_name, password => $password ); if ( $res->code ) { warn "LDAP bind failed as kohauser $userid: " . description($res); - return -1; + if ( $res->code == 34 ) { # invalid DN, probably local user + return 0; # fallback to local auth + } else { + return -1; # invalid password + } } if ( !defined($userldapentry) && ( $config{update} or $config{replicate} ) ) -- 1.9.1