Bug 10384 - Software error when LDAP connexion fails
Summary: Software error when LDAP connexion fails
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Authentication (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Fridolin Somers
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-31 08:15 UTC by Fridolin Somers
Modified: 2014-12-07 20:03 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Proposed patch (2.06 KB, patch)
2013-05-31 08:30 UTC, Fridolin Somers
Details | Diff | Splinter Review
Proposed patch (2.05 KB, patch)
2013-06-04 15:20 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 10384 - Software error when LDAP connexion fails (2.11 KB, patch)
2013-06-23 06:59 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10384 - Software error when LDAP connexion fails (2.18 KB, patch)
2013-07-05 12:42 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2013-05-31 08:15:53 UTC
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.
Comment 1 Fridolin Somers 2013-05-31 08:30:24 UTC Comment hidden (obsolete)
Comment 2 Galen Charlton 2013-05-31 19:25:11 UTC
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.
Comment 3 Fridolin Somers 2013-06-04 15:20:04 UTC Comment hidden (obsolete)
Comment 4 Chris Cormack 2013-06-23 06:59:48 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall (khall) 2013-07-05 12:42:53 UTC
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>
Comment 6 Galen Charlton 2013-07-05 16:16:02 UTC
Pushed to master.  Thanks, Fridolyn!
Comment 7 Tomás Cohen Arazi (tcohen) 2013-07-15 23:47:09 UTC
This patch has been pushed to 3.12.x, will be in 3.12.2.

Thanks Fridolyn!
Comment 8 Bernardo Gonzalez Kriegel 2013-08-03 20:14:23 UTC
Pushed to 3.10.x, will be in 3.10.10
Comment 9 Chris Hall 2013-08-18 04:33:05 UTC
Pushed to 3.8.x, will be in 3.8.17