From 37172b5148b85798fa4fbc209dcd790ba3a04791 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Wed, 12 Dec 2007 15:30:38 -0600 Subject: [PATCH] Auth_with_ldap: support non-RFC#2798 user IDs. Signed-off-by: Joshua Ferraro --- C4/Auth_with_ldap.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index 76026282b3..297f878f7c 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -30,7 +30,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug); BEGIN { require Exporter; - $VERSION = 3.01; # set the version for version checking + $VERSION = 3.02; # set the version for version checking $debug = $ENV{DEBUG} || 0; @ISA = qw(Exporter); @EXPORT = qw( checkpw_ldap ); @@ -38,7 +38,7 @@ BEGIN { # Redefine checkpw_ldap: # connect to LDAP (named or anonymous) -# ~ retrieves $userid from "uid" +# ~ retrieves $userid from KOHA_CONF mapping # ~ then compares $password with userPassword # ~ then gets the LDAP entry # ~ and calls the memberadd if necessary @@ -77,7 +77,8 @@ sub checkpw_ldap { my ($dbh, $userid, $password) = @_; my $db = Net::LDAP->new([$prefhost]); #$debug and $db->debug(5); - my $filter = Net::LDAP::Filter->new("uid=$userid") or die "Failed to create new Net::LDAP::Filter"; + my $uid_field = $mapping{userid}->{is} or die ldapserver_error("mapping for 'userid'"); + my $filter = Net::LDAP::Filter->new("$uid_field=$userid") or die "Failed to create new Net::LDAP::Filter"; my $res = ($config{anonymous}) ? $db->bind : $db->bind($ldapname, password=>$ldappassword); if ($res->code) { # connection refused warn "LDAP bind failed as $ldapname: " . description($res); -- 2.39.5