Created
November 27, 2013 15:18
-
-
Save underscorephil/7677420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('softlayer-api-php-client/SoftLayer/SoapClient.class.php'); | |
$apiUsername = ''; | |
$apiKey = ''; | |
$accountClient = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey); | |
$userClient = SoftLayer_SoapClient::getClient('SoftLayer_User_Customer', null, $apiUsername, $apiKey); | |
$virtualGuestClient = SoftLayer_SoapClient::getClient('SoftLayer_Virtual_Guest', null, $apiUsername, $apiKey); | |
$accountClient->setObjectMask("mask[id, userStatus, username]"); | |
$users = $accountClient->getUsers(); | |
$userToDisable = 'username'; | |
// Loop through each user on the account and identify by username | |
foreach ($users as $user) { | |
if ($user->username == $userToDisable) { | |
// set the userId for the userClient | |
$userClient->setInitParameter($user->id); | |
// Shutdown a users CCIs | |
$ccis = $userClient->getVirtualGuests(); | |
foreach ($ccis as $cci) { | |
$virtualGuestClient->setInitParameter($cci->id); | |
$virtualGuestClient->powerOffSoft(); | |
} | |
// Disable the user | |
$templateObject = new stdClass(); | |
$templateObject->id = $user->id; | |
$templateObject->userStatusId = 1002; // 1001 for enabled | |
$result = $userClient->editObject($templateObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment