* Admin/Active Directory: fixed not working display, setting and removing of "must change password upon next login"

This commit is contained in:
Ralf Becker 2013-07-13 07:51:40 +00:00
parent d716c8756f
commit dc7f8e11b1
2 changed files with 10 additions and 6 deletions

View File

@ -948,7 +948,7 @@
$var['changepassword'] = !$acl->check('nopasswordchange',1,'preferences') ? '  X' : ' '; $var['changepassword'] = !$acl->check('nopasswordchange',1,'preferences') ? '  X' : ' ';
if (!isset($auth)) $auth =& CreateObject('phpgwapi.auth'); if (!isset($auth)) $auth =& CreateObject('phpgwapi.auth');
$accLPWDC = $auth->getLastPwdChange($userData['account_lid']); $accLPWDC = $auth->getLastPwdChange($userData['account_lid']);
if ($accLPWC !== false) $userData['account_lastpwd_change'] = $accLPWDC; if ($accLPWDC !== false) $userData['account_lastpwd_change'] = $accLPWDC;
$var['mustchangepassword']= (isset($userData['account_lastpwd_change']) && ((is_string($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']==="0")||(is_int($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']===0)) ? '  X' : ' '); $var['mustchangepassword']= (isset($userData['account_lastpwd_change']) && ((is_string($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']==="0")||(is_int($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']===0)) ? '  X' : ' ');
unset($acl); unset($acl);
@ -1318,7 +1318,7 @@
$userData['changepassword'] = !$acl->check('nopasswordchange',1,'preferences'); $userData['changepassword'] = !$acl->check('nopasswordchange',1,'preferences');
if (!isset($auth)) $auth =& CreateObject('phpgwapi.auth'); if (!isset($auth)) $auth =& CreateObject('phpgwapi.auth');
$accLPWDC = $auth->getLastPwdChange($userData['account_lid']); $accLPWDC = $auth->getLastPwdChange($userData['account_lid']);
if ($accLPWC !== false) $userData['account_lastpwd_change'] = $accLPWDC; if ($accLPWDC !== false) $userData['account_lastpwd_change'] = $accLPWDC;
$userData['mustchangepassword'] = (isset($userData['account_lastpwd_change']) && ((is_string($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']==="0")||(is_int($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']===0))?true:false); $userData['mustchangepassword'] = (isset($userData['account_lastpwd_change']) && ((is_string($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']==="0")||(is_int($userData['account_lastpwd_change']) && $userData['account_lastpwd_change']===0))?true:false);
unset($acl); unset($acl);
} }

View File

@ -481,8 +481,8 @@ class accounts_ads
'account_status' => $data['useraccountcontrol'][0] & 2 ? false : 'A', 'account_status' => $data['useraccountcontrol'][0] & 2 ? false : 'A',
'account_expires' => !isset($data['accountexpires']) || $data['accountexpires'][0] == self::EXPIRES_NEVER ? -1 : 'account_expires' => !isset($data['accountexpires']) || $data['accountexpires'][0] == self::EXPIRES_NEVER ? -1 :
$this->adldap->utilities()->convertWindowsTimeToUnixTime($data['accountexpires'][0]), $this->adldap->utilities()->convertWindowsTimeToUnixTime($data['accountexpires'][0]),
'account_lastpwd_change' => !isset($data['pwdlastset']) ? null : 'account_lastpwd_change' => !isset($data['pwdlastset']) ? null : (!$data['pwdlastset'][0] ? 0 :
$this->adldap->utilities()->convertWindowsTimeToUnixTime($data['pwdlastset'][0]), $this->adldap->utilities()->convertWindowsTimeToUnixTime($data['pwdlastset'][0])),
'account_created' => !isset($data['whencreated'][0]) ? null : 'account_created' => !isset($data['whencreated'][0]) ? null :
self::_when2ts($data['whencreated'][0]), self::_when2ts($data['whencreated'][0]),
'account_modified' => !isset($data['whenchanged'][0]) ? null : 'account_modified' => !isset($data['whenchanged'][0]) ? null :
@ -712,7 +712,8 @@ class accounts_ads
'account_status' => 'enabled', 'account_status' => 'enabled',
'account_primary_group' => 'primarygroupid', 'account_primary_group' => 'primarygroupid',
'account_expires' => 'expires', 'account_expires' => 'expires',
'mustchangepassword'=> 'change_password', //'mustchangepassword'=> 'change_password', // can only set it, but not reset it, therefore we set pwdlastset direct
'account_lastpwd_change' => 'pwdlastset',
//'account_phone' => 'telephone', not updated by accounts, only read so far //'account_phone' => 'telephone', not updated by accounts, only read so far
); );
$attributes = $ldap = array(); $attributes = $ldap = array();
@ -759,6 +760,9 @@ class accounts_ads
case 'account_status': case 'account_status':
$attributes[$adldap] = $data[$egw] == 'A'; $attributes[$adldap] = $data[$egw] == 'A';
break; break;
case 'account_lastpwd_change': // AD only allows to set 0 (force pw change) and -1 (reset time)
$ldap[$adldap] = !$data[$egw] ? 0 : -1;
break;
default: default:
$attributes[$adldap] = $data[$egw]; $attributes[$adldap] = $data[$egw];
break; break;
@ -775,7 +779,7 @@ class accounts_ads
// attributes not (yet) suppored by adldap // attributes not (yet) suppored by adldap
if ($ldap && !($ret = @ldap_modify($ds=$this->ldap_connection(), $old['account_dn'], $ldap))) if ($ldap && !($ret = @ldap_modify($ds=$this->ldap_connection(), $old['account_dn'], $ldap)))
{ {
error_log(__METHOD__."(".array2string($data).") ldap_modify($ds, '$old[account_dn]', ".array2string($ldap).') returned '.array2string($ret).' '.function_backtrace()); error_log(__METHOD__."(".array2string($data).") ldap_modify($ds, '$old[account_dn]', ".array2string($ldap).') returned '.array2string($ret).' ('.ldap_error($ds).') '.function_backtrace());
return false; return false;
} }
//elseif ($ldap) error_log(__METHOD__."(".array2string($data).") ldap_modify($ds, '$old[account_dn]', ".array2string($ldap).') returned '.array2string($ret).' '.function_backtrace()); //elseif ($ldap) error_log(__METHOD__."(".array2string($data).") ldap_modify($ds, '$old[account_dn]', ".array2string($ldap).') returned '.array2string($ret).' '.function_backtrace());