* Admin/ImportExport: fixed import of already hashed passwords

This commit is contained in:
Ralf Becker 2012-03-29 18:33:33 +00:00
parent 545ffcf34e
commit a3ada52adf
4 changed files with 38 additions and 28 deletions

View File

@ -165,8 +165,11 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
admin_cmd::$acl->delete_repository('preferences','nopasswordchange',$data['account_id']);
}
}
// for existing accounts we have to change the password explicitly (at least that's what the old UI does)
if($this->account && !is_null($this->password))
// if we have a password and it's not a hash, and auth_type != account_repository
if (!is_null($this->password) &&
!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$this->password) &&
!preg_match('/^[0-9a-f]{32}$/',$this->password) && // md5 hash
admin_cmd::$accounts->config['auth_type'] != admin_cmd::$accounts->config['account_repository'])
{
admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw
}

View File

@ -308,5 +308,4 @@ class admin_import_users_csv implements importexport_iface_import_plugin {
public function get_results() {
return $this->results;
}
} // end of iface_export_plugin
?>
}

View File

@ -569,7 +569,11 @@ class accounts_ldap
$utc_diff = date('Z');
if (isset($data['account_passwd']) && $data['account_passwd'])
{
if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd'])) // if it's not already entcrypted, do so now
if (preg_match('/^[a-f0-9]{32}$/', $data['account_passwd'])) // md5 --> ldap md5
{
$data['account_passwd'] = setup_cmd_ldap::hash_sql2ldap($data['account_passwd']);
}
elseif (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd'])) // if it's not already entcrypted, do so now
{
$data['account_passwd'] = auth::encrypt_ldap($data['account_passwd']);
}

View File

@ -274,6 +274,10 @@ class setup_cmd_ldap extends setup_cmd
{
list(,$type,$hash) = $matches;
}
elseif (preg_match('/^[0-9a-f]{32}$/',$hash))
{
$type = 'md5';
}
switch(strtolower($type))
{
case 'plain':