From 906d5f24374eb190f6b7a00523fb16e5e683ac81 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 19 Sep 2012 02:10:41 +0200 Subject: Better way to create lists. --- lib/Fripost/Schema.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/Fripost/Schema.pm') 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 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 ); -- cgit v1.2.3