aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema.pm
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-19 02:10:41 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-19 02:10:41 +0200
commit906d5f24374eb190f6b7a00523fb16e5e683ac81 (patch)
tree61494ece954501a11f02552a140982aed854cbd3 /lib/Fripost/Schema.pm
parent9881490f8c578555aa2349f8223104aa22fc8954 (diff)
Better way to create lists.
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 );