Skip to content

Instantly share code, notes, and snippets.

@underscorephil
Created November 27, 2013 15:18
Show Gist options
  • Save underscorephil/7677420 to your computer and use it in GitHub Desktop.
Save underscorephil/7677420 to your computer and use it in GitHub Desktop.
<?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