2016-07-18 21:38:14 +02:00
|
|
|
package Lemonldap::NG::Portal::Password::LDAP;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
|
|
|
use Lemonldap::NG::Portal::Main::Constants qw(PE_PASSWORD_OK PE_LDAPERROR);
|
2016-07-20 22:47:43 +02:00
|
|
|
use Lemonldap::NG::Portal::Lib::LDAP;
|
2016-07-18 21:38:14 +02:00
|
|
|
|
2016-07-20 22:47:43 +02:00
|
|
|
extends 'Lemonldap::NG::Portal::UserDB::LDAP',
|
|
|
|
'Lemonldap::NG::Portal::Password::Base';
|
2016-07-18 21:38:14 +02:00
|
|
|
|
|
|
|
our $VERSION = '2.0.0';
|
|
|
|
|
|
|
|
sub init {
|
|
|
|
my ($self) = @_;
|
2016-07-20 22:47:43 +02:00
|
|
|
$self->ldap
|
|
|
|
and $self->filter
|
|
|
|
and $self->Lemonldap::NG::Portal::Password::Base::init;
|
2016-07-18 21:38:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Confirmation is done by Lib::LDAP::userModifyPassword
|
|
|
|
sub confirm {
|
2016-07-20 22:47:43 +02:00
|
|
|
return 1;
|
2016-07-18 21:38:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub modifyPassword {
|
|
|
|
my ( $self, $req, $pwd ) = @_;
|
|
|
|
|
|
|
|
# Call the modify password method
|
2016-07-20 22:47:43 +02:00
|
|
|
my $code =
|
|
|
|
$self->ldap->userModifyPassword( $req->{dn}, $pwd, $self->{oldpassword} );
|
2016-07-18 21:38:14 +02:00
|
|
|
|
|
|
|
unless ( $code == PE_PASSWORD_OK ) {
|
|
|
|
$self->ldap->unbind;
|
|
|
|
$self->{flags}->{ldapActive} = 0;
|
|
|
|
return $code;
|
|
|
|
}
|
|
|
|
|
|
|
|
# If password policy and force reset, set reset flag
|
|
|
|
if ( $self->{ldapPpolicyControl}
|
|
|
|
and $self->{forceReset}
|
|
|
|
and $self->{ldapUsePasswordResetAttribute} )
|
|
|
|
{
|
|
|
|
my $result = $self->ldap->modify(
|
|
|
|
$self->{dn},
|
|
|
|
replace => {
|
|
|
|
$self->{ldapPasswordResetAttribute} =>
|
|
|
|
$self->{ldapPasswordResetAttributeValue}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
unless ( $result->code == 0 ) {
|
|
|
|
$self->lmLog(
|
|
|
|
"LDAP modify "
|
|
|
|
. $self->{ldapPasswordResetAttribute}
|
|
|
|
. " error: "
|
|
|
|
. $result->code,
|
|
|
|
'error'
|
|
|
|
);
|
|
|
|
$self->ldap->unbind;
|
|
|
|
$self->{flags}->{ldapActive} = 0;
|
|
|
|
return PE_LDAPERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->lmLog(
|
|
|
|
$self->{ldapPasswordResetAttribute}
|
|
|
|
. " set to "
|
|
|
|
. $self->{ldapPasswordResetAttributeValue},
|
|
|
|
'debug'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $code;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|