From 328712af0d6a4131be4eedd61030e519a85673c6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 1 Sep 2015 18:46:07 +0000 Subject: [PATCH] fix not working setup/setup-cli.php --setup-cmd-ldap ,, sub_command=passwords_to_sql --- setup/inc/class.setup_cmd_ldap.inc.php | 12 +++++++++--- setup/setup-cli.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/setup/inc/class.setup_cmd_ldap.inc.php b/setup/inc/class.setup_cmd_ldap.inc.php index 83ec93a477..7a3a8147f6 100644 --- a/setup/inc/class.setup_cmd_ldap.inc.php +++ b/setup/inc/class.setup_cmd_ldap.inc.php @@ -45,10 +45,10 @@ * - copies mail-attributes from ldap to AD (example is from Mandriva mailAccount schema, need to adapt to other schema!) * (no_sid_check=1 uses all objectClass=posixAccount, not checking for having a SID and uid not ending in $ for computer accounts) * - * setup/setup-cli.php [--dry-run] --setup_cmd_ldap ,, sub_command=passwords_to_sql \ - * ldap_base=dc=local ldap_root_dn=cn=admin,dc=local ldap_root_pw=secret ldap_host=localhost + * setup/setup-cli.php [--dry-run] --setup-cmd-ldap ,, sub_command=passwords_to_sql \ + * ldap_context=ou=accounts,dc=local ldap_root_dn=cn=admin,dc=local ldap_root_pw=secret ldap_host=localhost * - * Updating passwords for existing users in SQL from LDAP, eg. to switch off authentication to LDAP on a SQL install. + * - updating passwords for existing users in SQL from LDAP, eg. to switch off authentication to LDAP on a SQL install. */ class setup_cmd_ldap extends setup_cmd { @@ -464,6 +464,12 @@ class setup_cmd_ldap extends setup_cmd $what = ($account['account_type'] == 'u' ? lang('User') : lang('Group')).' '. $account_id.' ('.$account['account_lid'].')'; + // if we migrate passwords from an authentication source, we need to use account_lid, not numerical id + if ($passwords2sql && ($id = $accounts_obj->name2id($account['account_lid'], 'account_lid', 'u'))) + { + $account_id = $id; + } + // invalidate cache: otherwise no migration takes place, if cached results says account already exists accounts::cache_invalidate($account_id); diff --git a/setup/setup-cli.php b/setup/setup-cli.php index aa2036a347..70195b3a0c 100755 --- a/setup/setup-cli.php +++ b/setup/setup-cli.php @@ -126,7 +126,7 @@ switch($action) is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) { $args = array(); - $args['domain'] = array_shift($arguments); // domain must be first argument, to ensure right domain get's selected in header-include + list($args['domain']) = explode(',', array_shift($arguments)); // domain must be first argument, to ensure right domain get's selected in header-include foreach($arguments as $arg) { list($name,$value) = explode('=',$arg,2);