Lines 59-65
my $prefhost = $ldap->{hostname} or die ldapserver_error('hostname');
Link Here
|
59 |
my $base = $ldap->{base} or die ldapserver_error('base'); |
59 |
my $base = $ldap->{base} or die ldapserver_error('base'); |
60 |
$ldapname = $ldap->{user} ; |
60 |
$ldapname = $ldap->{user} ; |
61 |
$ldappassword = $ldap->{pass} ; |
61 |
$ldappassword = $ldap->{pass} ; |
62 |
$ldap->{anonymous_bind} = 1 unless $ldapname && $ldappassword; |
|
|
63 |
our %mapping = %{$ldap->{mapping}}; # FIXME dpavlin -- don't die because of || (); from 6eaf8511c70eb82d797c941ef528f4310a15e9f9 |
62 |
our %mapping = %{$ldap->{mapping}}; # FIXME dpavlin -- don't die because of || (); from 6eaf8511c70eb82d797c941ef528f4310a15e9f9 |
64 |
my @mapkeys = keys %mapping; |
63 |
my @mapkeys = keys %mapping; |
65 |
$debug and print STDERR "Got ", scalar(@mapkeys), " ldap mapkeys ( total ): ", join ' ', @mapkeys, "\n"; |
64 |
$debug and print STDERR "Got ", scalar(@mapkeys), " ldap mapkeys ( total ): ", join ' ', @mapkeys, "\n"; |
Lines 76-82
if(defined $ldap->{categorycode_mapping}) {
Link Here
|
76 |
} |
75 |
} |
77 |
|
76 |
|
78 |
my %config = ( |
77 |
my %config = ( |
79 |
anonymous => ($ldapname and $ldappassword) ? 0 : 1, |
78 |
anonymous => defined ($ldap->{anonymous_bind}) ? $ldap->{anonymous_bind} : 1, |
80 |
replicate => defined($ldap->{replicate}) ? $ldap->{replicate} : 1, # add from LDAP to Koha database for new user |
79 |
replicate => defined($ldap->{replicate}) ? $ldap->{replicate} : 1, # add from LDAP to Koha database for new user |
81 |
update => defined($ldap->{update} ) ? $ldap->{update} : 1, # update from LDAP to Koha database for existing user |
80 |
update => defined($ldap->{update} ) ? $ldap->{update} : 1, # update from LDAP to Koha database for existing user |
82 |
); |
81 |
); |
Lines 127-133
sub checkpw_ldap {
Link Here
|
127 |
# first, LDAP authentication |
126 |
# first, LDAP authentication |
128 |
if ( $ldap->{auth_by_bind} ) { |
127 |
if ( $ldap->{auth_by_bind} ) { |
129 |
my $principal_name; |
128 |
my $principal_name; |
130 |
if ( $ldap->{anonymous_bind} ) { |
129 |
if ( $config{anonymous} ) { |
131 |
|
130 |
|
132 |
# Perform an anonymous bind |
131 |
# Perform an anonymous bind |
133 |
my $res = $db->bind; |
132 |
my $res = $db->bind; |
Lines 155-161
sub checkpw_ldap {
Link Here
|
155 |
# Perform a LDAP bind for the given username using the matched DN |
154 |
# Perform a LDAP bind for the given username using the matched DN |
156 |
my $res = $db->bind( $principal_name, password => $password ); |
155 |
my $res = $db->bind( $principal_name, password => $password ); |
157 |
if ( $res->code ) { |
156 |
if ( $res->code ) { |
158 |
if ( $ldap->{anonymous_bind} ) { |
157 |
if ( $config{anonymous} ) { |
159 |
# With anonymous_bind approach we can be sure we have found the correct user |
158 |
# With anonymous_bind approach we can be sure we have found the correct user |
160 |
# and that any 'code' response indicates a 'bad' user (be that blocked, banned |
159 |
# and that any 'code' response indicates a 'bad' user (be that blocked, banned |
161 |
# or password changed). We should not fall back to local accounts in this case. |
160 |
# or password changed). We should not fall back to local accounts in this case. |
Lines 176-182
sub checkpw_ldap {
Link Here
|
176 |
$userldapentry = $search->shift_entry; |
175 |
$userldapentry = $search->shift_entry; |
177 |
} |
176 |
} |
178 |
} else { |
177 |
} else { |
179 |
my $res = ($ldap->{anonymous_bind}) ? $db->bind : $db->bind($ldapname, password=>$ldappassword); |
178 |
my $res = ($config{anonymous}) ? $db->bind : $db->bind($ldapname, password=>$ldappassword); |
180 |
if ($res->code) { # connection refused |
179 |
if ($res->code) { # connection refused |
181 |
warn "LDAP bind failed as ldapuser " . ($ldapname || '[ANONYMOUS]') . ": " . description($res); |
180 |
warn "LDAP bind failed as ldapuser " . ($ldapname || '[ANONYMOUS]') . ": " . description($res); |
182 |
return 0; |
181 |
return 0; |