diff options
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 |