Skip to content

Commit

Permalink
Item14538: simplified patch, added config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Nov 24, 2017
1 parent d737945 commit 881305c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
2 changes: 2 additions & 0 deletions data/System/LdapContrib.txt
Expand Up @@ -499,6 +499,8 @@ This work is partly sponsored by
---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 25 Nov 2017: | added feature to specify multiple LDAP servers; \
added connection timeout |
| 10 Oct 2017: | fixed encoding errors of uncicode DN paths |
| 30 Aug 2017: | fixed checking local groups; fixed recoding values coming from the LDAP directory |
| 16 Jan 2017: | fixed logging in via email using an ldap-apache login manager |
Expand Down
35 changes: 14 additions & 21 deletions lib/Foswiki/Contrib/LdapContrib.pm
Expand Up @@ -30,8 +30,8 @@ use Encode ();
use Foswiki::Func ();
use Foswiki::Plugins ();

our $VERSION = '7.80';
our $RELEASE = '10 Oct 2017';
our $VERSION = '7.90';
our $RELEASE = '24 Nov 2017';
our $SHORTDESCRIPTION = 'LDAP services for Foswiki';
our $NO_PREFS_IN_TOPIC = 1;
our %sharedLdapContrib;
Expand Down Expand Up @@ -155,6 +155,7 @@ sub new {
host => $Foswiki::cfg{Ldap}{Host} || 'localhost',
base => $Foswiki::cfg{Ldap}{Base} || '',
port => $Foswiki::cfg{Ldap}{Port} || 389,
timeout => $Foswiki::cfg{Ldap}{Timeout} || 5,
version => $Foswiki::cfg{Ldap}{Version} || 3,
ipv6 => $Foswiki::cfg{Ldap}{IPv6} || 0,
ignoreReferrals => $Foswiki::cfg{Ldap}{IgnoreReferrals} || 0,
Expand Down Expand Up @@ -355,25 +356,17 @@ sub connect {
if ( $host =~ /,/) {
# This server preference list relies on the behaviour of Net::LDAP
# ldap://, ldaps:// URIs or host:port pairs are valid
my @hosts = split (/,/, $host);
$this->{ldap} = Net::LDAP->new(
\@hosts,
port => $port,
version => $this->{version},
inet4 => ($this->{ipv6}?0:1),
inet6 => ($this->{ipv6}?1:0),
timeout => 5, # TODO: make configurable
);
} else {
$this->{ldap} = Net::LDAP->new(
$host,
port => $port,
version => $this->{version},
inet4 => ($this->{ipv6}?0:1),
inet6 => ($this->{ipv6}?1:0),
timeout => 5, # TODO: make configurable
);
}
$host = [split (/\s*,\s*/, $host)];
}

$this->{ldap} = Net::LDAP->new(
$host,
port => $port,
version => $this->{version},
inet4 => ($this->{ipv6}?0:1),
inet6 => ($this->{ipv6}?1:0),
timeout => $this->{timeout},
);

unless ($this->{ldap}) {
$this->{error} = "failed to connect to $this->{host}";
Expand Down
11 changes: 9 additions & 2 deletions lib/Foswiki/Contrib/LdapContrib/Config.spec
Expand Up @@ -11,13 +11,20 @@
# ---+++ Connection settings

# **STRING**
# IP address (or hostname) of the LDAP server
# IP address (or hostname) of one or multiple LDAP servers. Multiple server URIs may be specified
# comma separated. Each will be tried in order until a connection is made. Please note that the
# system might slow down considerably if some of the servers are not reachable.
$Foswiki::cfg{Ldap}{Host} = 'ldap.my.domain.com';

# **NUMBER**
# Port used when binding to the LDAP server
# Port used when binding to the LDAP server. Note that this setting is overridden by any port specification
# part of the Host URI(s).
$Foswiki::cfg{Ldap}{Port} = 389;

# **NUMBER**
# Connection timeout talking to the LDAP server.
$Foswiki::cfg{Ldap}{Timeout} = 5;

# **BOOLEAN**
# Switch on this flag to enable IPv6 support when connecting to the LDAP server.
# Note that IPv6+SSL is still considered experimental. When disabled a normal IPv4 connection is established.
Expand Down

0 comments on commit 881305c

Please sign in to comment.