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 /home/fsomers/workspace/versions/community_master/C4/Auth_with_ldap.pm line 134, <DATA> line 558. This error should be avoided to allow normal authentication when LDAP connexion fails.
Created attachment 18540 [details] [review] Proposed patch See commit message
Comment on attachment 18540 [details] [review] Proposed patch Review of attachment 18540 [details] [review]: ----------------------------------------------------------------- ::: C4/Auth_with_ldap.pm @@ +103,5 @@ > my ($dbh, $userid, $password) = @_; > my @hosts = split(',', $prefhost); > my $db = Net::LDAP->new(\@hosts); > + unless ( $db ) { > + $debug and warn "LDAP connexion failed"; I think this might be better as a plain warn -- being unable to connect to the LDAP server is an operational problem that should be logged.
Created attachment 18641 [details] [review] Proposed patch Here is a new patch with warn regardless to debug mode.
Created attachment 19197 [details] [review] 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, <DATA> 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 : <useldapserver>1</useldapserver> <ldapserver id="ldapserver"> <hostname>localhost</hostname> <base>dc=test,dc=com</base> <user>cn=Manager,dc=test,dc=com</user> <pass>passwd</pass> <replicate>0</replicate> <update>0</update> <auth_by_bind>0</auth_by_bind> <mapping> <firstname is="givenname" ></firstname> <surname is="sn" ></surname> <branchcode is="branch" >MAIN</branchcode> <userid is="uid" ></userid> <password is="userpassword" ></password> <email is="mail" ></email> <categorycode is="employeetype" >PT</categorycode> </mapping> </ldapserver> - 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 <chris@bigballofwax.co.nz>
Created attachment 19403 [details] [review] 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, <DATA> 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 : <useldapserver>1</useldapserver> <ldapserver id="ldapserver"> <hostname>localhost</hostname> <base>dc=test,dc=com</base> <user>cn=Manager,dc=test,dc=com</user> <pass>passwd</pass> <replicate>0</replicate> <update>0</update> <auth_by_bind>0</auth_by_bind> <mapping> <firstname is="givenname" ></firstname> <surname is="sn" ></surname> <branchcode is="branch" >MAIN</branchcode> <userid is="uid" ></userid> <password is="userpassword" ></password> <email is="mail" ></email> <categorycode is="employeetype" >PT</categorycode> </mapping> </ldapserver> - 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 <chris@bigballofwax.co.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Pushed to master. Thanks, Fridolyn!
This patch has been pushed to 3.12.x, will be in 3.12.2. Thanks Fridolyn!
Pushed to 3.10.x, will be in 3.10.10
Pushed to 3.8.x, will be in 3.8.17