allow to migrate accounts from ADS to SQL

This commit is contained in:
Ralf Becker 2017-11-09 15:25:11 +01:00
parent a4ebc6e814
commit 628e7596d3
3 changed files with 18 additions and 9 deletions

View File

@ -1020,14 +1020,22 @@ class Storage
* - "accounts" accounts to ldap
* - "accounts-back" accounts back to sql (for sql-ldap!)
* - "sql" contacts and accounts to sql
* - "accounts-back-ads" accounts back from ads to sql
*/
function migrate2ldap($type)
{
//error_log(__METHOD__."(".array2string($type).")");
$sql_contacts = new Sql();
// we need an admin connection
$ds = $GLOBALS['egw']->ldap->ldapConnect();
$ldap_contacts = new Ldap(null, $ds);
if ($type == 'accounts-back-ads')
{
$ldap_contacts = new Ads();
}
else
{
// we need an admin connection
$ds = $GLOBALS['egw']->ldap->ldapConnect();
$ldap_contacts = new Ldap(null, $ds);
}
if (!is_array($type)) $type = explode(',', $type);

View File

@ -46,7 +46,7 @@ if (!is_object($GLOBALS['egw_setup']->db))
}
// Load configuration values account_repository and auth_type, as setup has not yet done so
foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',
"config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type' OR config_name='mail_suffix'",
"config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type' OR config_name='mail_suffix' OR config_name LIKE 'ads_%'",
__LINE__,__FILE__) as $row)
{
$GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value'];

View File

@ -442,12 +442,12 @@ class setup_cmd_ldap extends setup_cmd
{
$msg[] = $this->create();
}
else
elseif ($this->account_repository !== 'ads')
{
$msg[] = $this->connect();
}
// read accounts from old store
$accounts = $this->accounts($to == 'sql' ? 'ldap' : 'sql', $passwords2sql ? 'accounts' : 'both');
$accounts = $this->accounts($to == 'sql' ? $this->account_repository : 'sql', $passwords2sql ? 'accounts' : 'both');
// clean up SQL before migration
if ($to == 'sql' && $this->truncate_egw_accounts)
@ -543,7 +543,7 @@ class setup_cmd_ldap extends setup_cmd
$accounts_created++;
// check if we need to migrate mail-account
if (!isset($ldap_class))
if (!isset($ldap_class) && $this->account_repository !== 'ads')
{
$ldap_class = false;
$ldap = Api\Ldap::factory(false);
@ -666,7 +666,8 @@ class setup_cmd_ldap extends setup_cmd
}
}
ob_start();
$addressbook->migrate2ldap($to != 'sql' ? 'accounts' : 'accounts-back');
$addressbook->migrate2ldap($to != 'sql' ? 'accounts' : 'accounts-back'.
($this->account_repository == 'ads' ? '-ads' : ''));
$msgs = array_merge($msg, explode("\n", strip_tags(ob_get_clean())));
$this->restore_db();
@ -775,7 +776,7 @@ class setup_cmd_ldap extends setup_cmd
parent::_setup_enviroment($this->domain);
$enviroment_setup = true;
}
if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect
if ($type != 'sql' && $type != 'ads') $this->connect(); // throws exception, if it can NOT connect
// otherwise search does NOT work, as accounts_sql uses addressbook_bo for it
$GLOBALS['egw_info']['server']['account_repository'] = $type;