aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fripost/Schema.pm')
-rw-r--r--lib/Fripost/Schema.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Fripost/Schema.pm b/lib/Fripost/Schema.pm
index 3e89e6c..35c69e2 100644
--- a/lib/Fripost/Schema.pm
+++ b/lib/Fripost/Schema.pm
@@ -73,13 +73,21 @@ I<CFG> should contain definitions for the LDAP suffix and URI.
sub auth {
my $class = shift;
- my ($l,$d) = split /\@/, shift, 2;
+ my $id = shift;
my $pw = shift;
my %cfg = @_;
my $self = bless {}, $class;
$self->suffix( join ',', @{$cfg{ldap_suffix}} );
- $self->whoami( "fvu=$l,fvd=$d,".$self->suffix );
+
+ if (not (defined $id) or defined $cfg{ldap_bind_dn}) {
+ $self->whoami( $cfg{ldap_bind_dn} );
+ }
+ else {
+ my ($l,$d) = split /\@/, $id, 2;
+ $self->whoami( "fvu=$l,fvd=$d,".$self->suffix );
+ }
+
$self->ldap( Net::LDAP::->new( $cfg{ldap_uri}, async => 1 ) );
my $mesg = $self->ldap->bind( $self->whoami, password => $pw );