Friday, November 19, 2010

Kerberos Logging

I recently encountered a bug in a program that was using a Vb6 COM object to call the MAPI COM objects. There was very little information about what the problem was - no logging, nothing in the event log. The problem though, was a Kerberos authentication failure. I had to turn on Kerberos logging before I could see it. This powershell script is useful for doing that:

#Useful: http://support.microsoft.com/kb/262177
#Read the state of the Kerberos Loggin Registry Key
Get-ItemProperty -Path hklm:\\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters\ -Name LogLevel

#Turn on Kerberos Logging
Set-ItemProperty -Path hklm:\\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters\ -Name LogLevel -Value 1

#Turn Kerberos Logging off
#The KB Article said to turn it off so that performance was not adversely affected after the logging was obtained.
Set-ItemProperty -Path hklm:\\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters\ -Name LogLevel -Value 0

#Retrieve Event Log Entries related to Kerberos
Get-EventLog System | Where { $_.Source -eq "Kerberos" }

Monday, November 1, 2010


This is a wireless thermometer. It transmits the temperature in the small greenhouse on my balcony to my computer. From there, I can email myself if the temperature in the greenhouse approaches freezing or just post the temperature on the web for fun.

There are three components here:

  1. An Arduino.
  2. An XBee wireless module.
  3. A Temperature sensor. 
The arduino is programmed to read the voltage from the temperature sensor, convert it to a text string, and then send it over the XBee transmitter to the XBee receiver which is connected to my computer's serial port. 

This is the arduino code:
#include <NewSoftSerial.h>

NewSoftSerial mySerial
= NewSoftSerial(2, 3);

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
Serial.begin(
9600);

Serial.println(
"Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println(
"Hello, world");
}

void loop() {
float voltage = 5.0*analogRead(0)/1024;
float temperatureC = (voltage - 0.5) * 100;
float temperatureF = (temperatureC * 9 / 5) + 32;

Serial.print(temperatureF); Serial.println(
" degrees F ");

mySerial.print(temperatureF); mySerial.println(
" degrees F ");

delay(
1000);
}

The SoftSerial library is very useful. It enables serial communications on any two digital io pins.

The following powershell code reads the temperature from the XBee module and uploads it to a WebService:

$portName = "COM4"
$url = "http://ogresoft.com/Temperature/Home/SetTemperature?Temperature="
$delay = 60

$serialPort = New-Object "System.IO.Ports.SerialPort"
$serialPort.PortName = $portName
$serialPort.Open()

while($true) {
$temperature = $serialPort.ReadLine()
Write-Host $temperature
$request = [System.Net.HttpWebRequest]::Create($url + [DateTime]::Now.ToString() + " " + $temperature)
$response = $request.GetResponse()
Write-Host ([DateTime]::Now.ToString() + " " + $response.StatusCode)
Sleep $delay
}