Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120801545
20130611.nukeldap.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jul 7, 04:49
Size
973 B
Mime Type
text/x-php
Expires
Wed, Jul 9, 04:49 (2 d)
Engine
blob
Format
Raw Data
Handle
27214624
Attached To
rPH Phabricator
20130611.nukeldap.php
View Options
<?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
();
echo
"Migrating LDAP to ExternalAccount...
\n
"
;
$rows
=
queryfx_all
(
$conn_w
,
'SELECT * FROM %T'
,
$table_name
);
foreach
(
$rows
as
$row
)
{
echo
"Migrating row ID #"
.
$row
[
'id'
].
".
\n
"
;
$user
=
id
(
new
PhabricatorUser
())->
loadOneWhere
(
'id = %d'
,
$row
[
'userID'
]);
if
(!
$user
)
{
echo
"Bad user ID!
\n
"
;
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
);
}
}
echo
"Done.
\n
"
;
Event Timeline
Log In to Comment