2013-06-16 18:55:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// NOTE: We aren't using PhabricatorUserLDAPInfo anywhere here because it is
|
|
|
|
// being nuked by this change
|
|
|
|
|
|
|
|
$table = new PhabricatorUser();
|
|
|
|
$table_name = 'user_ldapinfo';
|
|
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
|
|
|
|
$xaccount = new PhabricatorExternalAccount();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating LDAP to %s...', 'ExternalAccount')."\n";
|
2013-06-16 18:55:55 +02:00
|
|
|
|
|
|
|
$rows = queryfx_all($conn_w, 'SELECT * FROM %T', $table_name);
|
|
|
|
foreach ($rows as $row) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating row ID #%d.', $row['id'])."\n";
|
2013-06-16 18:55:55 +02:00
|
|
|
$user = id(new PhabricatorUser())->loadOneWhere(
|
|
|
|
'id = %d',
|
|
|
|
$row['userID']);
|
|
|
|
if (!$user) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Bad user ID!')."\n";
|
2013-06-16 18:55:55 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$xaccount = id(new PhabricatorExternalAccount())
|
|
|
|
->setUserPHID($user->getPHID())
|
|
|
|
->setAccountType('ldap')
|
|
|
|
->setAccountDomain('self')
|
|
|
|
->setAccountID($row['ldapUsername'])
|
|
|
|
->setUsername($row['ldapUsername'])
|
|
|
|
->setDateCreated($row['dateCreated']);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$xaccount->save();
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
phlog($ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|