Update Bandwidth Limit via Command Line

If you’ve ever wanted to update the bandwidth limit via command-line, without needing to login to WHM, this post is for you! I was surprise with how simple this was.

  1. Manually edit line beginning with “BWLIMIT=” in /var/cpanel/users/
  2. Get your modification recognized by running the script below
    /scripts/updateuserdomains
  3. There is no step 3!

{ 0 comments }

For the impatient, simply upgrade to at least WHMCS 5.2.2!

Per WHMCS support…

In the latest version of WHMCS we introduced a new session handling class which includes a random session name per install. We also updated the standard WHMCS verify image to use this new class and not call session start itself.

Full back-story and resolution for those not running version 5.2.2, are unable to do the upgrade, or perhaps experienced trouble with this fix.

For the impatient, simply add this line to the end of your configuration.php file.

session_name("WHMCS");

For those interested in the full story …

Since right around the time we installed WHMCS version 5.1.2 in July 2012, we had been receiving an “Invalid Token” error periodically, yet quite regularly, when submitting a form on WHMCS (support ticket reply, invoice, etc.).

We opened a ticket with WHMCS support in August explaining the issue, hoping for that a response that would quickly resolve the issue. Unfortunately, that didn’t happen :( The support team kept saying the error was due to the PHP session expiring and that it was essentially an issue with the hosting provider. With session.gc_maxlifetime set to 24 minutes we were surprised to see the Session ID change after only a few minutes.

In March 2013, our team finally tracked down the cause of this issue …

WHMCS by default uses the PHPSESSID cookie to track its session. If there are any other PHP applications on the domain which use the same cookie, it can cause a conflict which in WHMCS results in an “Invalid Token” error. It took us a while to track this down as the other apps on the domain gracefully recovered from the shared cookie.

To resolve the issue, we added the line of code below to our configuration.php file.

session_name("WHMCS");

Now the session cookie is called WHMCS and does not conflict with the other PHP applications on the domain.

Did this help you? Show some love with a comment!

{ 16 comments }

Configure Office365 Passwords to Not Expire

**UPDATED 11/13/2013 to reflect usage of Windows Azure Active Directory Module for Windows PowerShell.

  1. Download & install the Microsoft Online Services Sign-In Assistant for IT Professionals BETA
  2. Download & install the Windows Azure Active Directory Module for Windows PowerShell
    (32-Bit | 64-Bit)
  3. Launch PowerShell and ensure we have loaded the Office365 Module
    Import-Module msonline
  4. Connect to Office365 using Administrative Credentials
    $cred = Get-Credential
    Connect-MsolService -cred $cred
  5. Set all user’s passwords to never expire
    Get-MsolUser | Set-MsolUser -PasswordNeverExpires $True

    To set a single user’s password to not expire

    Set-MsolUser -UserPrincipalName user@domain.tld -PasswordNeverExpires $false
  6. Confirm users passwords are set to not expire (Optional)
    Get-MsolUser | fl UserPrincipalName,PasswordNeverExpires

Thanks to Jan Egil for her great blog post which helped me figure this out and subsequently a TechNet article for the 11/13/2013 update.

{ 0 comments }

Unable to remove user from Google Analytics

I recently encountered an issue where I was unable remove a user from a Google Analytics profile. Immediate Googling was unsuccessful so I began playing around. Turns out, you cannot remove an administrator; you must first assign the “User” role to the account you wish to remove.

{ 0 comments }

I was playing around with node.js on EC2 the other day and ran into some trouble installing npm. I was getting this error

[]$ curl http://npmjs.org/install.sh | sudo sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
101  7881  101  7881    0     0  94200      0 --:--:-- --:--:-- --:--:--  148k
npm cannot be installed without nodejs.
Install node first, and then try again.
 
Maybe node is installed, but not in the PATH?
Note that running as sudo can change envs.
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin

My initial attempt at finding a resolution revolved around trying to update the path env setting used by sudo. After spending some fruitless time on this I switched gears and came across Michael Dillon‘s Stack Overflow post which recommended setting up some symlinks to resolve the path issues.

sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf

Minutes later npm was up and running!

{ 2 comments }

We were recently transitioned to Office365 and learned that certain settings and permissions did come across during the upgrade. This meant that some settings and permissions needed to be reconfigured via PowerShell. Back in the days of BPOS, you needed the Migration ToolKit installed in order to use any of the Microsoft Online related PowerShell Cmd-Lets. With Office365, you don’t need this! Instead, you need to open a server side connection to the cloud servers from your local machine. Below are the steps to do this.

  1. Load your Office365 credentials in a variable
    $Cred = Get-Credential
  2. Create a session variable which will configure a connection to the cloud servers
    $Sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
  3. Initialize the session
    Import-PSSession $Sess
  4. Run any of the Exchange Online Cmdlets found in the documentation.
  5. Once you’re done running commands, you can close the session
    Remove-PSSession $Sess

Note: The guts of this post came from a Microsoft Article which I never was able to come across in my searching, but rather was pointed to via a service request.

{ 0 comments }

**NOTE** You will need to have compiler access on your shared hosting account in order for the instructions below to work. You can request your host enable this, or pass these instructions along to them and request they compile git for you.

From SSH:

cd
wget http://git-core.googlecode.com/files/git-1.7.9.2.tar.gz
tar zxvf git-1.7.9.2.tar.gz
cd git-1.7.9.2
./configure --prefix=/home/$USER
make
make install
echo 'PATH=$PATH:$HOME/bin' >> $HOME/.bashrc
source $HOME/.bashrc

If you get the error “bash: /usr/bin/wget: Permission denied” you can try downloading the git source with the command

curl -O http://git-core.googlecode.com/files/git-1.7.9.2.tar.gz

{ 7 comments }

Windows XP Guest Reboots Continuously

I recently purchased a new Lenovo T410 with an i7 processor to replace my T410 with an i5 processor. While I’m a heavy user of Dropbox for files and portable versions of many applications I use on a daily basis, I tend not to place my Virtual Machines on Dropbox … go figure :-p. This saves me a ton of time when setting up a new machine since my documents, photos, etc. are automagically copied to the machine once Dropbox has been installed. Add LAN sync to the picture and you’ve got a pretty fast way to provision a new machine

In the process of preparing my new machine, I installed VirtualBox and manually copied over the VDI and XML configuration files. Everything was looking good, until I tried starting one VM which of course had some very important software running on it.

The VM kept rebooting, again and again without stopping to show me the BSOD detailing why. Figuring it was something to do with the drivers I booted into safe mode and tried uninstalling and reinstalling VBox Addons. After rebooting, I was once again caught in the never ending reboot cycle.

I jumped back into safe mode and disabled the automatic reboot after a BSOD (See http://support.microsoft.com/kb/174630 for details on doing this) and rebooted once again, with my fingers crossed.

Success! I was finally able to see the cause of of the BSOD:

Stop 0x000000CE (0xF7A3C8F8, 0x00000000, 0xF7A3C8F8, 0x00000000)

Stop: 0x000000CE (0xF7A3C8F8, 0x00000000, 0xF7A3C8F8, 0x00000000)

intelppm.sys

So now I have something Google/Bing that actually describes what’s happening. Moments later, I come across a Tickt #420 – http://www.virtualbox.org/ticket/420, which references this Stop error, but isn’t an exact match to my symptoms. At this point, I’m willing to try pretty much anything to get my VM back up and running, so I follow xok’s instructions

  1. Boot Into Safe Mode + Networking (F8 @ startup)
  2. Go to %Systemroot%\Inf\ and delete all OEM#.inf
  3. Search for intelppm.sys in the c:\windows\ (search for hidden directories and system files) – Delete the 3 results of intelppm.sys
  4. Reboot the Guest
  5. Reinstall VBox Additions (might need to do this a couple times to get everything functioning @ 100%)

And BOOM! I’m back alive.

{ 12 comments }

Trigger SSRS Subscriptions Manually

Looking to resend a single SSRS subscription?

In a nutshell, subscriptions are configured via the Report Manager which then configures and are later triggered by a SQL Server Agent Job based on a Schedule ID. This schedule ID can be tied back to a report and a particular subscription owned by a user with the ReportSchedule table. From this point, you can then query the Subscriptions to see the associated User.

  1. Within the Report Manager, browse to edit page of the subscription you would like to manually trigger
  2. Locate the SubscriptionID GUID in the address bar
  3. Open SQL Server Management Studio (SSMS) and connect to the server with the ReportServer Database
  4. Run the query below replacing the SubscriptionID with what you found in step 3
  5. SELECT ScheduleID
    FROM ReportSchedule
    WHERE (SubscriptionID = '04109b04-aaaa-bbbb-cccc-fe271bde49a4')

  6. Manually execute the subscription without modifying the schedule with the query below, be sure to replace the EventData parameter with the ScheduleID returned in step 4.
  7. EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription', 
    @EventData='805cd511-cccc-bbbb-aaaa-3746daff3b95'

Want to dig a bit deeper? Starting with these tables will give you a head start.

ReportSchedule – Relationships between Schedules, Reports and Subscriptions
Schedule – Details of all schedules
Subscriptions – Subscription details including owners, last run status, parameters, etc.
Users – Ties the Owner’s GUID to a username

{ 4 comments }

We recently migrated a client from SugarCRM to a lighter-weight, custom built, Drupal 7 CRM solution that more tightly met their needs. (The decision making process of moving away from SugarCRM as well as the migration/implmentation could be it’s own multi-part blog post).

Our client has several landing pages they use for lead generation and had previously used SugarCRM’s SOAP and REST APIs to capture this information directly in SugarCRM as a lead. Naturally they wanted similar functionality when moving to Drupal. We had always heard of the power of the Services module, but never had the chance to work with it in production. This was our chance!

The documentation for the services module was good, but didn’t really provide many code examples that could be used by someone looking for a quick start. I began poking around and quickly fell in love with the REST Server provided by the services module and decided it was the way to go.

With a bit of guidance from kylebrowning, I wrote a simple class to make our implementation a bit simpler by abstracting some of the details such as session tracking. I wrote DrupalREST.PHP and threw it on github.

After creating a content type in our Drupal installation with some CCK fields, we used the 19 lines of code below to create the node/lead.

$api = new DrupalRESTWebServices('http://url/to/your/endpoint', 'username', 'password', FALSE);
$node = array (
	'name' => 'creator',
	'status' => 1,
	'type' => 'content_type',
	'field_status' => array('und' =>array('key' => '1')),
	'field_first_name' => array('und' => array(array('value' => $form_values['submitted']['first_name']['#value']))),
	'field_last_name' => array('und' => array(array('value' => $form_values['submitted']['last_name']['#value']))),
	'field_phone_number' => array('und' => array(array('value' => $form_values['submitted']['phone']['#value']))),
	'field_address' => array('und' => array(array('value' => $form_values['submitted']['address']['#value']))),
	'field_city' => array('und' => array(array('value' => $form_values['submitted']['city']['#value']))),
	'field_state' => array('und' => array(array('value' => $form_values['submitted']['state']['#value']))),
	'field_zip' => array('und' => array(array('value' => $form_values['submitted']['zip']['#value']))),
	'field_email' => array('und' => array(array('value' => $form_values['submitted']['email']['#value']))),
	'field_lead_source' => array('und' => array(array('value' => $form_values['submitted']['source']['#value']))),
	'field_google_keyword' => array('und' => array(array('value' => $form_values['submitted']['keyword']['#value']))),
);
$api->login();
$api->createNode(array('node' => $node));

Let me know if this helped you get started with Drupal Services Module & the REST Server by leaving a comment!

NOTE: I ported this to C# as DrupalREST.NET.

{ 3 comments }