Skip to content

Commit

Permalink
Account for inappropriate LDAP Auth
Browse files Browse the repository at this point in the history
Needed for blank passwords. [#103 state:resolved]
  • Loading branch information
theory committed Nov 13, 2009
1 parent bbf81d3 commit 642add9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Bric/Util/AuthLDAP.pm
Expand Up @@ -37,7 +37,7 @@ use strict;
# Programmatic Dependencies
use Bric::Config qw(:ldap);
use Bric::Util::Fault qw(throw_auth);
use Net::LDAP qw(LDAP_INVALID_CREDENTIALS LDAP_SUCCESS);
use Net::LDAP qw(LDAP_INVALID_CREDENTIALS LDAP_SUCCESS LDAP_INAPPROPRIATE_AUTH);
use Net::LDAP::Util qw(ldap_error_desc);
use Net::LDAP::Filter;

Expand Down Expand Up @@ -82,8 +82,11 @@ sub authenticate {
version => LDAP_VERSION,
onerror => sub {
my $mesg = shift;
my $code = $mesg->code;
# Invalid credentials are okay.
return $mesg if $mesg->code == LDAP_INVALID_CREDENTIALS;
return $mesg if grep { $_ == $code }
LDAP_INVALID_CREDENTIALS,
LDAP_INAPPROPRIATE_AUTH;
throw_auth "LDAP Error: " . ldap_error_desc($mesg);
}
) or throw_auth error => "Unable to connect to LDAP Server", payload => $@;
Expand Down
1 change: 1 addition & 0 deletions t/Bric/Util/AuthEngines/Test.pm
Expand Up @@ -124,6 +124,7 @@ BEGIN {
my $caller = caller or return;
no strict 'refs';
*{"${caller}::LDAP_INVALID_CREDENTIALS"} = sub () { 49 };
*{"${caller}::LDAP_INAPPROPRIATE_AUTH"} = sub () { 48 };
*{"${caller}::LDAP_SUCCESS"} = sub () { 0 };
}
my $ldap = bless {};
Expand Down

0 comments on commit 642add9

Please sign in to comment.