Commit d89f853d authored by Francesc Guasch's avatar Francesc Guasch
Browse files

feat(CLI): change LDAP password

parent d485ef4e
......@@ -185,7 +185,7 @@ sub default_object_class() {
return @OBJECT_CLASS;
}
sub _password_store($password, $storage, $algorithm) {
sub _password_store($password, $storage, $algorithm=undef) {
return _password_rfc2307($password, $algorithm) if lc($storage) eq 'rfc2307';
return _password_pbkdf2($password, $algorithm) if lc($storage) eq 'pbkdf2';
......
......@@ -533,6 +533,10 @@ sub change_password {
die "Password too small" if length($password)<6;
if ($self->is_external) {
return $self->_change_password_external($password);
}
my $sth;
if (defined($force_change_password)) {
$sth= $$CON->dbh->prepare("UPDATE users set password=?, change_password=?"
......@@ -545,6 +549,23 @@ sub change_password {
}
}
sub _change_password_external($self,$password) {
if ($self->external_auth eq 'ldap') {
my $ldap_entry = $self->ldap_entry() or die "Error: no ldap entry";
$ldap_entry->replace(
userPassword => Ravada::Auth::LDAP::_password_store($password,'rfc2307'));
my $ldap = Ravada::Auth::LDAP::_init_ldap_admin();
my $mesg = $ldap_entry->update($ldap);
die "ERROR: ".$mesg->code." : ".$mesg->error
if $mesg->code;
} else {
confess
"Error: I don't know how to change external password for ".$self->external_auth;
}
}
=head2 compare_password
Changes the input with the password of an User
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment