X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FAuth%2FLDAP.pm;h=2f651b3a7578c4a05ad9ecdc43b43f013cf4a5dc;hb=0829f390c4ff388edc78c2c1475797ae74436776;hp=b42bf8702da4ed450c2f728cf58963fba826e054;hpb=211f4e60ebc94a7fd73564ca750f7f52f416773f;p=kivitendo-erp.git diff --git a/SL/Auth/LDAP.pm b/SL/Auth/LDAP.pm index b42bf8702..2f651b3a7 100644 --- a/SL/Auth/LDAP.pm +++ b/SL/Auth/LDAP.pm @@ -32,27 +32,32 @@ sub _connect { return $self->{ldap} if $self->{ldap}; - my $port = $cfg->{port} || 389; - $self->{ldap} = Net::LDAP->new($cfg->{host}, 'port' => $port); + my $port = $cfg->{port} || 389; + my $ldap = Net::LDAP->new($cfg->{host}, port => $port, timeout => $cfg->{timeout} || 10); - if (!$self->{ldap}) { - $main::form->error($main::locale->text('The LDAP server "#1:#2" is unreachable. Please check config/kivitendo.conf.', $cfg->{host}, $port)); + if (!$ldap) { + $::lxdebug->warn($main::locale->text('The LDAP server "#1:#2" is unreachable. Please check config/kivitendo.conf.', $cfg->{host}, $port)); + return undef; } if ($cfg->{tls}) { - my $mesg = $self->{ldap}->start_tls('verify' => 'none'); + my $mesg = $ldap->start_tls(verify => $cfg->{verify} // 'require'); if ($mesg->is_error()) { - $main::form->error($main::locale->text('The connection to the LDAP server cannot be encrypted (SSL/TLS startup failure). Please check config/kivitendo.conf.')); + $::lxdebug->warn($main::locale->text('The connection to the LDAP server cannot be encrypted (SSL/TLS startup failure). Please check config/kivitendo.conf.')); + return undef; } } if ($cfg->{bind_dn}) { - my $mesg = $self->{ldap}->bind($cfg->{bind_dn}, 'password' => $cfg->{bind_password}); + my $mesg = $ldap->bind($cfg->{bind_dn}, 'password' => $cfg->{bind_password}); if ($mesg->is_error()) { - $main::form->error($main::locale->text('Binding to the LDAP server as "#1" failed. Please check config/kivitendo.conf.', $cfg->{bind_dn})); + $::lxdebug->warn($main::locale->text('Binding to the LDAP server as "#1" failed. Please check config/kivitendo.conf.', $cfg->{bind_dn})); + return undef; } } + $self->{ldap} = $ldap; + return $self->{ldap}; }