Fetching Mobile Data Usage & Talk Time From Orange

The “Your Orange” app on my Android based phone requests this URL:

http://tellus.orange.co.uk/content/yourorange/config.xml

Inside the returned XML there is this element:

<mobileAccountAPI href="https://www.youraccount.orange.co.uk/eCare/api/balance"/>

Requesting the https://www.youraccount… URL and providing the same username/password you would use to access your account details at www.youraccount.orange.co.uk, you get back XML which includes elements like this:

<description>
  Mobile Internet 250MB
</description>
<unitsRemaining>
  196.0313
</unitsRemaining>

There is an <unbilledSummary> element that has the current charges incurred for Talk, Data and SMS.

Mac Active Directory Network Users

Login using an Active Directory user was easy to setup, but there are a few issues that need to be solved. The first is that if you enable a password on wake up, then you can’t wake up the Mac. There is a fix but it required editing a file in /etc .

The fix is here: http://support.apple.com/kb/TS3287

A New Mac

I have owned Macs since the late 80′s but having just got one at work, it is the first time I have had to use one in a corporate environment. It is an almost exclusively Windows environment with Active Directory, DFS, Group Policies etc.

Attaching it to Active Directory was quite simple via System Preferences -> Accounts -> Login Options. I then added one of our domain controllers to the Network Account Servers. You will need the username and password of a domain admin to do this. I also made sure I enabled “Allow network users to log in at login window” and set the Display login window as “Name and password”

What is funny is that adding the Mac to the domain did not require a reboot, in Windows it does!

When It Goes Dark The Light Comes On

I got my first Arduino a few days ago, but it wasn’t until today that I managed to get down to the local electronics store to buy a few bits to connect to it. This simple project is the result.

IMG_3134

It’s been a long time since a dozen lines of code has put a smile on my face like this did tonight.

The new 150 in 1 Electronics Kits

I have just been looking at the Arduino kits you can buy on-line. They remind me of those 150 in 1 electronic kits you could get when I was a kid.

The question is, how do I get my wife to agree that they would make a good present for one of the kids? Her argument will be that I am one of the kids which is difficult to disagree with.

Timestamp_Sys100NS to Python datetime

The WMI performance counters on Windows have a timestamp value in the field “Timestamp_Sys100NS”. To convert this to a more useable datetime use follow this example code:

epoch = datetime.datetime( 1601, 1, 1, 0, 0, 0 )
wmic = wmi.WMI( find_classes = False )
pd = wmic.Win32_PerfRawData_PerfOS_Processor( Name = "_Total" )[0]
ts = epoch + datetime.timedelta( microseconds =  pd.Timestamp_Sys100NS / 10.0)

Cloning Ubuntu Server 7.10 on VMware ESX

After cloning a virtual machine running Ubuntu Server 7.10 I found that it didn’t have any network available. Restarting networking gave:

sudo /etc/init.d/networking restart
 
 * Reconfiguring network interfaces...
eth0: ERROR while getting interface flags: No such device
SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
eth0: ERROR while getting interface flags: No such device
eth0: ERROR while getting interface flags: No such device
Failed to bring up eth0.

The problem lies in the fact that ethernet MAC addresses are cached. You need to remove a file to clear the cached value:

sudo rm /etc/udev/rules.d/70-persistent-net.rules

After a restart of your server you should have networking back again.

I also had to edit the following files to change the static ip addresses and hostname:

  • /etc/hosts – change ip address and hostnames
  • /etc/hostname – change hostname
  • /etc/network/interfaces – change ip address

CasPol and DFS shares

My previous post on CasPol is great for ordinary shares, but for DFS it doesn’t work. To solve this you need to add your share into the LocalIntranet zone by doing this:

caspol -machine -addgroup "LocalIntranet_Zone" -url "file:///&lt;dfs share path&gt;" FullTrust

CasPol Is Your Friend

Blogs are great for jotting down the usage of commands that you use very rarely. This posting is one of these cases. (This is actually the second time I have made this note, but the first one got lost in wiki that was destroyed some time ago.)

The issue I had was that on a new machine I got the following error when running some .net code from a network share:

An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll

After a little searching a remembered the answer. It was to use caspol like this:

caspol -machine -chggroup Internet_Zone FullTrust

Python IIS Virtual Directory Administration

Today I wanted to add, update and delete virtual directories on a number of IIS servers.

To connect to the IIS servers I use:

import win32com.client
 
locator = win32com.client.Dispatch( 'WbemScripting.SWbemLocator' )
server = locator.ConnectServer( server_name, 'root/MicrosoftIISv2' )
server.Security_.authenticationLevel = 6 # wbemAuthenticationLevelPkt

Then to add a virtual directory called ‘name’ that maps to directory called ‘directory’ you need:

vdir_class = server.Get( "IIsWebVirtualDirSetting" )
 
vdir_settings = vdir_class.SpawnInstance_()
 
vdir_settings.Name = 'W3SVC/1/ROOT/' + name
vdir_settings.Path = directory
 
vdir_settings.Put_()

To update a virtual directory you need:

vdir_settings = server.Get( "IIsWebVirtualDirSetting='%s'" % ( 'W3SVC/1/ROOT/' + name ) )
 
vdir_settings.Path = directory
 
vdir_settings.Put_()

Finally, to delete a virtual directory you need:

vdir = server.Get( "IIsWebVirtualDirSetting='%s'" % ( 'W3SVC/1/ROOT/' + name ) )
 
vdir.Delete_()