diff options
author | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-04-18 22:28:17 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-04-18 22:28:17 +0200 |
commit | 5f15ee93f79af5af0ee064ffdb5c03f2af14ee3a (patch) | |
tree | 03d26f94a5e5e4514cccd4d0a456065688c4821f /lib/Fripost | |
parent | a1cee8071f753b80daf374af4bad8458657dd07a (diff) |
Unauthenticate binds; LDAP server defaults to ldap://127.0.0.1:389.
Diffstat (limited to 'lib/Fripost')
-rwxr-xr-x | lib/Fripost/Schema.pm | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/Fripost/Schema.pm b/lib/Fripost/Schema.pm index 14caccd..6a92be7 100755 --- a/lib/Fripost/Schema.pm +++ b/lib/Fripost/Schema.pm @@ -30,16 +30,30 @@ sub new { my $class = shift; my $h = shift; + $h->{server_host} //= 'ldap://127.0.0.1:389'; + $h->{base_dn} //= ''; + my $self = {_options => $h}; bless $self, $class; my $ldap = Net::LDAP->new ( $h->{server_host} ) - or die "Error: Cannot initialize connection to LDAP server.\n"; + or die "Error: Cannot initialize connection to LDAP server at `" + .$h->{server_host}. "'.\n"; my $mesg; if ( (defined $h->{bind_dn}) and $h->{bind_dn} ne '' ) { - $self->_dsay( "Binding to DN `" .$h->{bind_dn}. "'." ); - $mesg = $ldap->bind( $h->{bind_dn}, password => $h->{bind_pw} ); + my %bind; + my $debug = "Binding to DN `" .$h->{bind_dn}. "'"; + if (defined $h->{bind_pw}) { + $debug .= " (authenticated)."; + $bind{password} = $h->{bind_pw}; + } + else { + $debug .= " (unauthenticated)."; + $bind{noauth} = 1; + } + $self->_dsay( $debug ); + $mesg = $ldap->bind( $h->{bind_dn}, %bind ); } else { # Anonymous bind |