2016-05-01 09:30:21 +02:00
|
|
|
package Lemonldap::NG::Portal::Auth::LDAP;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
2016-05-04 13:38:49 +02:00
|
|
|
use Lemonldap::NG::Portal::Main::Constants;
|
2016-05-01 09:30:21 +02:00
|
|
|
|
|
|
|
our $VERSION = '2.0.0';
|
|
|
|
|
2016-05-02 12:30:23 +02:00
|
|
|
# Inheritance: UserDB::LDAP provides all needed ldap functions
|
2016-05-01 09:30:21 +02:00
|
|
|
extends
|
|
|
|
qw(Lemonldap::NG::Portal::Auth::_WebForm Lemonldap::NG::Portal::UserDB::LDAP);
|
|
|
|
|
|
|
|
sub authenticate {
|
2016-05-04 13:38:49 +02:00
|
|
|
my ( $self, $req ) = @_;
|
2016-05-01 09:30:21 +02:00
|
|
|
unless ( $self->ldap ) {
|
|
|
|
return PE_LDAPCONNECTFAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set the dn unless done before
|
|
|
|
unless ( $req->datas->{dn} ) {
|
|
|
|
if ( my $tmp = $self->getUser($req) ) {
|
|
|
|
return $tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $res =
|
2016-05-04 13:38:49 +02:00
|
|
|
$self->ldap->userBind( $req->datas->{dn},
|
|
|
|
password => $req->datas->{password} );
|
2016-05-01 09:30:21 +02:00
|
|
|
|
|
|
|
# Remember password if password reset needed
|
|
|
|
$req->datas->{oldpassword} = $self->{password}
|
|
|
|
if ( $res == PE_PP_CHANGE_AFTER_RESET );
|
|
|
|
|
|
|
|
$self->ldap->unbind;
|
|
|
|
return $res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sub authLogout {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-02 12:30:23 +02:00
|
|
|
sub authForce {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-01 09:30:21 +02:00
|
|
|
1;
|