[Jifty-commit] r5299 - in jifty/trunk/lib/Jifty/Plugin/Authentication: Ldap/Action

Jifty commits jifty-commit at lists.jifty.org
Thu Apr 10 15:43:56 EDT 2008


Author: dpavlin
Date: Thu Apr 10 15:43:46 2008
New Revision: 5299

Modified:
   jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap.pm
   jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap/Action/LDAPLogin.pm

Log:
better logging and errors

Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap.pm	Thu Apr 10 15:43:46 2008
@@ -56,11 +56,12 @@
     my %args = @_;
 
     $params{'Hostname'} = $args{LDAPhost};
-    $params{'base'} = $args{LDAPbase};
+    $params{'base'} = $args{LDAPbase} or die "Need LDAPbase in plugin config";
     $params{'uid'} = $args{LDAPuid} || "uid";
     $params{'email'} = $args{LDAPMail} || "";
     $params{'name'} = $args{LDAPName} || "cn";
-    $LDAP = Net::LDAP->new($params{Hostname},async=>1,onerror => 'undef', debug => 0);
+    $LDAP = Net::LDAP->new($params{Hostname},async=>1,onerror => 'undef', debug => 0)
+        or die "Can't connect to LDAP server ",$params{Hostname};
 }
 
 sub LDAP {
@@ -94,6 +95,7 @@
             attrs  =>  [$self->name(),$self->email()],
             sizelimit => 1
              );
+    $result->code && Jifty->log->error( 'LDAP uid=' . $user . ' ' . $result->error );
     my ($ret) = $result->entries;
     my $name = $ret->get_value($self->name());
     my $email = $ret->get_value($self->email());

Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap/Action/LDAPLogin.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap/Action/LDAPLogin.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Ldap/Action/LDAPLogin.pm	Thu Apr 10 15:43:46 2008
@@ -66,15 +66,17 @@
     my $dn = $plugin->uid().'='.$username.','.
         $plugin->base();
 
+    Jifty->log->debug( "dn = $dn" );
 
     # Bind on ldap
     my $msg = $plugin->LDAP()->bind($dn ,'password' =>$self->argument_value('password'));
 
 
-    unless (not $msg->code) {
+    if ($msg->code) {
         $self->result->error(
      _('You may have mistyped your login or password. Give it another shot?')
         );
+        Jifty->log->error( "LDAP bind $dn " . $msg->error . "" );
         return;
     }
 


More information about the Jifty-commit mailing list