2013-04-28 16:44:03 +02:00
|
|
|
##@file
|
|
|
|
# AD password backend file
|
|
|
|
|
|
|
|
##@class
|
|
|
|
# AD password backend class
|
|
|
|
package Lemonldap::NG::Portal::PasswordDBAD;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Lemonldap::NG::Portal::Simple;
|
|
|
|
|
|
|
|
#inherits Lemonldap::NG::Portal::_SMTP
|
|
|
|
|
|
|
|
our $VERSION = '1.3.0';
|
|
|
|
|
|
|
|
use base qw(Lemonldap::NG::Portal::PasswordDBLDAP);
|
|
|
|
|
|
|
|
*_formateFilter = *Lemonldap::NG::Portal::UserDBAD::formateFilter;
|
2013-04-28 16:46:18 +02:00
|
|
|
*_search = *Lemonldap::NG::Portal::UserDBAD::search;
|
2013-04-28 16:44:03 +02:00
|
|
|
|
|
|
|
## @apmethod int modifyPassword()
|
|
|
|
# Modify the password by LDAP mechanism.
|
|
|
|
# Use AD specific method
|
|
|
|
# @return Lemonldap::NG::Portal constant
|
|
|
|
sub modifyPassword {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Exit method if no password change requested
|
|
|
|
return PE_OK unless ( $self->{newpassword} );
|
|
|
|
|
|
|
|
unless ( $self->ldap ) {
|
|
|
|
return PE_LDAPCONNECTFAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set the dn unless done before
|
|
|
|
unless ( $self->{dn} ) {
|
|
|
|
my $tmp = $self->_subProcess(qw(_formateFilter _search));
|
|
|
|
return $tmp if ($tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->lmLog( "Modify password request for " . $self->{dn}, 'debug' );
|
|
|
|
|
|
|
|
# Call the modify password method for AD
|
2013-06-01 15:40:29 +02:00
|
|
|
my $code =
|
|
|
|
$self->ldap->userModifyPassword( $self->{dn}, $self->{newpassword},
|
|
|
|
$self->{confirmpassword},
|
|
|
|
$self->{oldpassword}, 1 );
|
2013-04-28 16:44:03 +02:00
|
|
|
|
|
|
|
return $code unless ( $code == PE_PASSWORD_OK );
|
|
|
|
|
2013-06-03 00:00:33 +02:00
|
|
|
# If force reset, set reset flag
|
|
|
|
if ( $self->{forceReset} ) {
|
|
|
|
my $result =
|
|
|
|
$self->ldap->modify( $self->{dn},
|
|
|
|
replace => { 'pwdLastSet' => '0' } );
|
|
|
|
|
|
|
|
unless ( $result->code == 0 ) {
|
|
|
|
$self->lmLog( "LDAP modify pwdLastSet error: " . $result->code,
|
|
|
|
'error' );
|
|
|
|
$code = PE_LDAPERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->lmLog( "pwdLastSet set to 0", 'debug' );
|
|
|
|
}
|
2013-04-28 16:44:03 +02:00
|
|
|
|
|
|
|
return $code;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|