fix not working setup/setup-cli.php --setup-cmd-ldap <domain>,<config-user>,<config-pw> sub_command=passwords_to_sql

This commit is contained in:
Ralf Becker 2015-09-01 18:46:26 +00:00
parent 187406187b
commit c6395a1f5a
2 changed files with 10 additions and 4 deletions

View File

@ -45,10 +45,10 @@
* - copies mail-attributes from ldap to AD (example is from Mandriva mailAccount schema, need to adapt to other schema!) * - 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) * (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 <domain>,<config-user>,<config-pw> sub_command=passwords_to_sql \ * setup/setup-cli.php [--dry-run] --setup-cmd-ldap <domain>,<config-user>,<config-pw> sub_command=passwords_to_sql \
* ldap_base=dc=local ldap_root_dn=cn=admin,dc=local ldap_root_pw=secret ldap_host=localhost * 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 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')).' '. $what = ($account['account_type'] == 'u' ? lang('User') : lang('Group')).' '.
$account_id.' ('.$account['account_lid'].')'; $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 // invalidate cache: otherwise no migration takes place, if cached results says account already exists
accounts::cache_invalidate($account_id); accounts::cache_invalidate($account_id);

View File

@ -126,7 +126,7 @@ switch($action)
is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
{ {
$args = array(); $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) foreach($arguments as $arg)
{ {
list($name,$value) = explode('=',$arg,2); list($name,$value) = explode('=',$arg,2);