How to read data from a remote Windows registry using Python

Thursday, March 17th, 2011

It is easy to connect to a remote Windows machine and retrieve information from the registry using the Python Windows registry access module _winreg

from _winreg import *

reg = ConnectRegistry('computer123222', HKEY_LOCAL_MACHINE)
key = OpenKey(reg, 'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate',0,KEY_READ)
value = QueryValueEx(key, 'SusClientId')

ConnectRegistry() allows you to specify the remote computer and one of the HKEY constants like HKEY_LOCAL_MACHINE or HKEY_USERS.

OpenKey() specifies the remote registry as the location of the hive), the sub key, an integer of 0 (it  must be 0!) followed by the registry key access rights.

Joining Ubuntu Lucid to Active Directory

Friday, April 16th, 2010

The latest Ubuntu release (Ludid, 10.4) makes it very easy for you to join an Active Directory domain. Here’s a quick guide to get you started.

1. Install the likewise open AD authentication application by issuing the command sudo apt-get install likewise-open

2. Register your Ubuntu system with the domain by running sudo domainjoin-cli join yourdomainname.com administrator (where yourdomainname.com is your domain name, and administrator is a user account on the domain with permissions to add computers to it).

3. When prompted, enter the password of your adminstrator account. A dialogue box will appear asking for your domain name,  enter your AD fully qualified domain name in upper case letters, i.e YOURDOMAIN.COM

4. Finally reboot.

Want sudo privileges? Go to your Active Directory and create a group. I called mine sudo, but you can use any group you like. A word of advice though, you’ll have less problems if you don’t use spaces in your group name.

Switch to a local user account with sudo privleges and at the terminal issue the command sudo visudo

At the end of the sudoers file add this line

%YOURDOMAIN.COM\\sudo ALL=(ALL) ALL

This tells Ubuntu to allow any user in the sudo group on your AD to use sudo privileges on the local machine.

To login to your Ubuntu system at the GUI use username@yourdomain

To login over SSH use yourdomain\username

Sourceforge Bans ‘evil’ Nations from Uploading and Downloading Open Source Code

Wednesday, January 27th, 2010

The world got a little less open today as Sourceforge announced that it is to ban users from Iran, North Korea, Cuba, Sudan, and Syria from using its open source software repository.

Using IP address based blocking, users from countries on the US Office of Foreign Assets Control sanction list will no longer be able to contribute to or use code hosted on Sourceforge.

It would seem that although Sourceforge do not support this move, they feel that as occupants of the ‘real world’ they must remain reticent stating:

“…in addition to participating in the open source community, we also live in the real world, and are governed by the laws of the country in which we are located. Our need to follow those laws supersedes any wishes we might have to make our community as inclusive as possible.”

In the meantime, freedom lovers can go here for a list of other open source software hosting facilities.

Pirate Party UK Launches

Friday, June 12th, 2009

The Ubuntu-UK mailing list brings news of the emergence of the ‘Pirate Party UK‘ (PPUK).

Inspired by the Swedish Piratpartiet, the PPUK is a single issue political party campaigning principally for the reformation of copyright law and patent systems.

Interested in the political/legal concepts of Free Libre and Open Source software? Give PPUK a visit.

SugarCRM 5 – Installer Step 2: Writable Session Save Path Not A Valid Directory

Sunday, July 6th, 2008

Do you ever have one of those days when no matter what you try, you just can’t get a web application to work? I suffered the angst of this recently when trying to install SugarCRM 5 on a Plesk based shared hosting server.

No matter what I tried, in step 2 of the installation process I got an error about the writable session save path not being valid. I checked the path in the /etc/php.ini file, created a php test page using phpinfo() and checked that the php session location was writable. Still, the installer brought up the same error message.

Finally I resorted to hacking the install script. I thought I’d share the hack with you here just in case you suffer the same error as I! Open up the install/installSystemCheck.php file. Check out the example below, and notice that seventh line from the bottom, I have changed the variable $error_found = true; to $error_found = false;

That should move you onto install step 2.

// session save dir
$session_save_path = session_save_path();
if (strpos ($session_save_path, “;”) !== FALSE)
$session_save_path = substr ($session_save_path, strpos ($session_save_path, “;”)+1);
if(is_dir($session_save_path)){
if(is_writable($session_save_path)){
installLog(”Session Save Path is “.$session_save_path);
}else{
$save_pathStatus = “<b><span class=’stop’>{$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_WRITABLE']}</font></b>”;
installLog(”ERROR:: {$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_WRITABLE']}”);
$error_found = true;
$error_txt .= ‘
<tr>
<td><strong>’.$mod_strings['LBL_CHECKSYS_SESSION_SAVE_PATH'].’</strong></td>
<td class=”error”>’.$save_pathStatus.’</td>
</tr>’;
}
}else{
$save_pathStatus = “<b><span class=’stop’>{$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_SET']}</font></b>”;
installLog(”ERROR:: {$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_SET']}”);
$error_found = false;
$error_txt .= ‘
<tr>
<td><strong>’.$mod_strings['LBL_CHECKSYS_SESSION_SAVE_PATH'].’</strong></td>
<td class=”error”>’.$save_pathStatus.’</td>
</tr>’;
}

Microsoft Office 2007 to Support ODF

Wednesday, May 21st, 2008

I just read this on Slashdot and wondered what people thought of this seemingly bizarre move from MS?

After campaigning for OOXML so vigorously, MS have now announced that they will be issuing an update to Office 2007 to add support for OASIS ODF 1.1.

This won’t be available as the default format for saving, but even so – making support available for ODF and not supporting OOXML (that won’t come until a future version) must fatally damage OOXML as a standard.

Hopefully the delay in OOXML support and the emergance of ODF support as standard in an MS Office suite will herald new support by the public sector for the ODF format.

Who knows, the next time you visit your favorite government website you might be able to grab a copy of taxreturn.odt

Why Use an Open Source Licence?

Sunday, January 13th, 2008

OK, imagine if you will, that I suddenly developed uber programming skills and coded a great application for – lets say – keeping track of properties in an estate agency.

At this point I’m faced with a couple of choices (but please add more if you think of any):

1) Provide my software under a proprietary licence, charging my customer for both the software and my support of the software

2) Provide my software under an open-source licence, giving away the source code for free, but selling my support to the customer

At this point hypothetical software vendor Chris (much to freedom loving Chris’s disappointment) leans towards model 1. In this way I keep the source code of my uber application and corner the estate agent market.

As an advocate (albeit user of) open source software, my internal freedom loving Chris urges me to learn what the business benefits (to the vendor) of the open-source licensing model are.

Can anyone steer me in the right direction?