fixed problem with disabled Unix passwords
This commit is contained in:
parent
d201671bd9
commit
c1fbe22ee9
|
@ -1573,20 +1573,14 @@ function modifyuser($values,$values_old,$uselamdaemon=true) { // Will modify the
|
||||||
// Check if shadow expire has changed
|
// Check if shadow expire has changed
|
||||||
if ($values->unix_pwdexpire != $values_old->unix_pwdexpire) $attr['shadowExpire'] = intval($values->unix_pwdexpire / 86400) ;
|
if ($values->unix_pwdexpire != $values_old->unix_pwdexpire) $attr['shadowExpire'] = intval($values->unix_pwdexpire / 86400) ;
|
||||||
// Set unix password
|
// Set unix password
|
||||||
if ($values->unix_password=='') {
|
if ($values->unix_password=='') { // $values->unix_password=='' means use old password
|
||||||
// $values->unix_password=='' means use old password
|
if ($values->unix_deactivated != $values_old->unix_deactivated) { // check if password was enabled/disabled
|
||||||
if ($values->unix_deactivated != $values_old->unix_deactivated) {
|
if ($values->unix_deactivated) {
|
||||||
// (de)activate password
|
$attr['userPassword'] = pwd_disable($values_old->unix_password);
|
||||||
// Split old password hash in {CRYPT} and password-hash
|
}
|
||||||
$i = 0;
|
else {
|
||||||
while ($values_old->unix_password{$i} != '}') $i++;
|
$attr['userPassword'] = pwd_enable($values_old->unix_password);
|
||||||
$passwd = substr($values_old->unix_password, $i+1 );
|
}
|
||||||
$crypt = substr($values_old->unix_password, 0, $i+1 );
|
|
||||||
// remove trailing ! from password hash
|
|
||||||
if ($passwd{0} == '!') $passwd = substr($passwd, 1);
|
|
||||||
// Write new password
|
|
||||||
if ($values->unix_deactivated) $attr['userPassword'] = $crypt.'!'.$passwd;
|
|
||||||
else $attr['userPassword'] = $crypt.$passwd;
|
|
||||||
}
|
}
|
||||||
if ($values->unix_password_no) {
|
if ($values->unix_password_no) {
|
||||||
// use no password
|
// use no password
|
||||||
|
|
|
@ -133,6 +133,10 @@ class posixAccount {
|
||||||
return _('posixAccount');
|
return _('posixAccount');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_base_module() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* This function returns a list with all required modules
|
/* This function returns a list with all required modules
|
||||||
*/
|
*/
|
||||||
function get_dependencies($scope) {
|
function get_dependencies($scope) {
|
||||||
|
@ -256,16 +260,12 @@ class posixAccount {
|
||||||
else { // No new password but old password
|
else { // No new password but old password
|
||||||
// (un)lock password
|
// (un)lock password
|
||||||
if ($this->userPassword_lock == pwd_is_enabled($this->orig['userPassword'][0])) {
|
if ($this->userPassword_lock == pwd_is_enabled($this->orig['userPassword'][0])) {
|
||||||
// Split old password hash in {CRYPT} and password-hash
|
if ($this->userPassword_lock) {
|
||||||
$i = 0;
|
$return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode(pwd_disable($this->orig['userPassword'][0]));
|
||||||
while ($this->orig['userPassword'][0]{$i} != '}') $i++;
|
}
|
||||||
$passwd = substr($this->orig['userPassword'][0], $i+1 );
|
else {
|
||||||
$crypt = substr($this->orig['userPassword'][0], 0, $i+1 );
|
$return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode(pwd_enable($this->orig['userPassword'][0]));
|
||||||
// remove trailing ! from password hash
|
}
|
||||||
if ($passwd{0} == '!') $passwd = substr($passwd, 1);
|
|
||||||
// Write new password
|
|
||||||
if ($this->userPassword_lock) $return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode("$crypt!$passwd");
|
|
||||||
else $return[$_SESSION[$this->base]->dn]['modify']['userPassword'][0] = utf8_encode("$crypt$passwd");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue