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