diff --git a/api/src/Contacts/Storage.php b/api/src/Contacts/Storage.php index 38053a63f8..cf29d6e37c 100755 --- a/api/src/Contacts/Storage.php +++ b/api/src/Contacts/Storage.php @@ -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); diff --git a/setup/account_migration.php b/setup/account_migration.php index 6b9e1cfb32..626232a86b 100644 --- a/setup/account_migration.php +++ b/setup/account_migration.php @@ -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']; diff --git a/setup/inc/class.setup_cmd_ldap.inc.php b/setup/inc/class.setup_cmd_ldap.inc.php index 3e5101a00a..0275c4d95e 100644 --- a/setup/inc/class.setup_cmd_ldap.inc.php +++ b/setup/inc/class.setup_cmd_ldap.inc.php @@ -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;