2013-04-28 16:44:03 +02:00
|
|
|
##@file
|
|
|
|
# AD authentication backend file
|
|
|
|
|
|
|
|
##@class
|
|
|
|
# AD authentication backend class
|
|
|
|
package Lemonldap::NG::Portal::AuthAD;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2014-02-18 17:05:39 +01:00
|
|
|
our $VERSION = '1.4.0';
|
2013-09-28 00:22:27 +02:00
|
|
|
use Lemonldap::NG::Portal::Simple;
|
2013-04-28 16:44:03 +02:00
|
|
|
use base qw(Lemonldap::NG::Portal::AuthLDAP);
|
|
|
|
|
|
|
|
*_formateFilter = *Lemonldap::NG::Portal::UserDBAD::formateFilter;
|
2013-09-30 10:38:24 +02:00
|
|
|
*getDisplayType = *Lemonldap::NG::Portal::AuthLDAP::getDisplayType;
|
2013-04-28 16:44:03 +02:00
|
|
|
|
2014-02-18 17:05:39 +01:00
|
|
|
## @apmethod int authInit()
|
2013-09-28 00:22:27 +02:00
|
|
|
# Add specific attributes for search
|
|
|
|
# @return Lemonldap::NG::Portal constant
|
|
|
|
sub authInit {
|
|
|
|
my $self = shift;
|
|
|
|
|
2014-02-18 17:05:39 +01:00
|
|
|
$self->{ldapExportedVars}->{_AD_pwdLastSet} = 'pwdLastSet';
|
|
|
|
$self->{ldapExportedVars}->{_AD_userAccountControl} = 'userAccountControl';
|
2013-09-28 00:22:27 +02:00
|
|
|
|
|
|
|
return $self->SUPER::authInit();
|
|
|
|
}
|
|
|
|
|
2013-04-28 16:44:03 +02:00
|
|
|
## @apmethod int authenticate()
|
|
|
|
# Authenticate user by LDAP mechanism.
|
|
|
|
# Check AD specific attribute to get password state.
|
|
|
|
# @return Lemonldap::NG::Portal constant
|
|
|
|
sub authenticate {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $res = $self->SUPER::authenticate;
|
|
|
|
|
2013-09-28 00:22:27 +02:00
|
|
|
unless ( $res == PE_OK ) {
|
|
|
|
|
|
|
|
# Check specific AD attributes
|
|
|
|
my $pls = $self->{entry}->get_value('pwdLastSet');
|
|
|
|
|
|
|
|
# Password must be changed if pwdLastSet 0
|
|
|
|
if ( $pls == 0 ) {
|
|
|
|
$self->lmLog( "[AD] User must change its password", 'debug' );
|
|
|
|
return PE_PP_CHANGE_AFTER_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Remember password if password reset needed
|
|
|
|
$self->{oldpassword} = $self->{password}
|
|
|
|
if ( $res == PE_PP_CHANGE_AFTER_RESET );
|
2013-04-28 16:44:03 +02:00
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|