Troubleshooting Profiles

At work we recently moved to an Active Directory domain for all of our public computers to authenticate against.  This was a shift from a SAMBA-based domain, and we have had some issues that resulted from this migration.

One of the biggest issues has been in the area of user profiles.  People who log onto public computers have roaming profiles, which means that all of their user and application data is stored on a server somewhere, and downloaded each time the user logs in.  Changes made during that session are uploaded to the server, so the profile is always in sync.

However, going from one domain to another means that file ownership changes due to different SIDs.  Compounding the problem is that we get non-specific reports from the field, consisting of "Joe's profile is broken," with no further information.

To track down problems with user profiles, Windows supports extensive logging capabilities, which are not enabled by default.  To enable logging of user profiles, here is the process:

1.  In the Run dialog box, type regedit, and then click OK.

2. Locate the following subkey:
HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon

3. Create a new entry named UserEnvDebugLevel of data type REG_DWORD,
and set its value to 0x30002.

The log file is stored in this location: %windir%\Debug\Usermode\Userenv.log

I set this up on a test machine joined to the domain, so that when I receive reports of profile errors, I can log the problem user onto the domain and audit the resulting log file.

[tags]Windows,profiles,roaming,debug[/tags]

Remembering Challenger

546When I was ten years old, my world fell apart in 73 seconds. It was the first time I witnessed the death of another human being, and the raw pain of that day still has not left me.The year was 1986, and I was in third grade. My family had just moved to New Hampshire two months earlier, and I was amazed to see another New Hampshire resident, Christa McAuliffe, all over the evening news, in addition to Channel 9, the local news station. It was the dream of a little boy to reach for the stars, to go to space and look down upon the earth. I dreamed about it. I watched the shuttle launches. My grandfather lived in Florida, and would often tell me about being able to the see the shuttle soaring over his house.Because McAuliffe was a teacher from New Hampshire, my elementary school was very much involved in the entire process, and the students did projects and wrote letters to our New Hampshire astronaut. On the day of the launch, we all sat in front of a television in class to watch the teacher bring space right to our very classroom. I was so excited, and remember staring at the television, completely transfixed with anticipation. When the engines lit, my heart raced and we all cheered. When the shuttle cleared the launchpad, we all clapped. What happened next hushed the room like a forest covered in thick snow. Nobody spoke. I heard one of the teachers gasp. My heart sank. Someone turned off the television, and we resumed our normal class schedule. I could not focus, though, as all I could think of were white smoke trails across a blue sky.

I sobbed for three days straight. My dream to visit space someday was shattered, and I was acutely aware of the deaths of those astronauts, and that hurt the most. President Reagan's now famous speech made me weep as if my own family had been lost. And to this day, 20 years later, hearing that speech and watching video of Challenger's demise still brings me to tears.

"We will never forget them this morning as they prepared for their journey and waved goodbye and slipped the surly bonds of earth to touch the face of God."

[tags]Challenger, Christa+McAuliffe, NASA, New+Hampshire, Reagan, Space+Shuttle[/tags]

Custom Logon Text in Windows XP

We recently changed domains at work, and with over four hundred public machines on campus, I was looking for a way to remind the users to use the new domain, to reduce confusion.  There are two parts to this - changing the logon dialog box title, and adding custom text.

To change the text, fire up regedit and navigate to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\Winlogon

Create a new string value called "LogonPrompt", double-click on it and enter the text you want to display.

To change the dialog title, create a new string value called "Welcome", double-click on it and enter the text you want to appear in the title bar of the Windows logon dialog box.

Smarty and Capitalization Modifier

I do a lot of web design, and I use the Smarty templating engine for all of my PHP websites.  It is a fantastic template system, designed for rapid development, and it succeeds at everything it does.

Well, almost everything.

Smarty has modifiers, which allow you to control data dynamically in your templates.  A lot of people complain that this feature of Smarty puts too much logic in the template system, which by its very nature is supposed to seperate business logic from display logic.  However, some modifiers such as "capitalize" fit under display logic as far as I am concerned.  One limitation of this modifier is that it does not handle contractions very well at all.

Take this for example:

example.tpl:

{assign value="max's horse didn't fall. 'someone' is coming.  they're here!" var="capt"}
{$capt|capitalize}

Output:
Max'S Horse Didn'T Fall. 'Someone' Is Coming. They'Re Here!

As you can see, Smarty treats the apostrophe as a word boundary, resulting in incorrect capitalization.  The way to fix this behavior is to modify [smarty]/libs/plugins/modifier.capitalize.php.

function smarty_modifier_capitalize($string, $uc_digits = false)
{
//replace common contraction endings with placeholders
//that PCRE will not see as a word boundary
$apos = array('n\'t ','\'s ','\'re ');
$tmps = array('n__apos__t ','__apos__s ','__apos__re ');
$string = str_replace($apos,$tmps,$string);
//do the real work
smarty_modifier_capitalize_ucfirst(null, $uc_digits);
$string = preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
//restore the contractions and return
return str_replace($tmps,$apos,$string);
}

example.tpl:

{assign value="max's horse didn't fall. 'someone' is coming.  they're here!" var="capt"}
{$capt|capitalize}

Output:
Max's Horse Didn't Fall. 'Someone' Is Coming. They're Here!

[tags]Smarty,PHP,modifier,capitalize,template,display+logic[/tags]

VBscript Is Frustrating

I can't stand the way VBScript handles non-values.  Consider the following:

<pre><xmp>
strValue = SomeFunction()
 
If strValue = "" Then
' Do Something
Else
' Do Something Else
End If
</xmp></pre>

This fails unless your SomeFunction() function specifically returns an empty string, such as:
<pre><xmp>
strValue = SomeFunction()
 
If strValue = "" Then
' Do Something
Else
' Do Something Else
End If
 
Function SomeFunction()
SomeFunction = ""
End Function
</xmp></pre>

This is because even an empty string is considered a value in VBScript, on which you can check the length and check for IsEmpty().  However, this doesn't work if your function returns a variable that has no value, like this:
<pre><xmp>
strValue = SomeFunction()
 
If strValue = "" Then
' Do Something
Else
' Do Something Else
End If
 
Function SomeFunction()
strValue = SomeOtherFunction()
SomeFunction = strValue
End Function
</xmp></pre>

In this case, if the SomeOtherFunction() did not return a value, then the value of strValue is NULL.  In VBScript, a NULL is defined as "no valid data."  So, the only way to validate this variable is to check for NULL:
<pre><xmp>
strValue = SomeFunction()
 
If IsNull(strValue) Then
' Do Something
Else
' Do Something Else
End If
 
Function SomeFunction()
strValue = SomeOtherFunction()
SomeFunction = strValue
End Function
</xmp></pre>

Because strValue does not hold valid data, IsNull() evaluates to TRUE.  Now, in the case of objects, where you expect a function to return an object, you have to use a completely different method:
<pre><xmp>
Set objValue = SomeFunction()
 
If objValue Is Nothing Then
' Do Something
Else
' Do Something Else
End If
 
Function SomeFunction()
Set objValue = SomeOtherFunction()
Set SomeFunction = objValue
End Function
</xmp></pre>

Strange, and not entirely intuitive, but there it is...

G00gL3 4 h4x0rs

Looks like the clever folks over at GrayHats.com have created a special version of Google for those who speaks the language of gamerz and h4x0rz:

These people have too much time on their hands. It is pretty funny though...

Reno, NV Is A Fun Place To Live

Apparently, Reno, Nevada has invested a lot of time and money to beautify the city. Recently though, "graffiti artists" (also known as street punks), have been adding their own brand of beautification to highway landscaping. When such vile crime occurs, drastic measures must be taken.

At least, according to Oscar Goodman, mayor of Reno.

Goodman suggested that these ultra-violent criminals have their thumbs cut off on live television. The mayor made these comments while appearing on a local television show "Nevada Newsmakers," and also suggested a return to canings and whippings.

In 2004, the city reported 1,480 violent crimes, broken down as such:

  • 9 murders
  • 112 rapes
  • 464 robberies
  • 895 aggravated assaults

There were 10,154 property crimes, all falling under the categories of burglaries or thefts.

I wonder what the good mayor would suggest as punishment for the fine people who committed these crimes. So let's hear it for another great idea from our politicians - clearly Reno, Nevada has got a handle on the best way to protect its citizens.

I'll definitely be moving there next week...

PHP and SOAP Authentication

One of my recent projects for a customer of mine, ResortScope, LLC, involved setting up some web services to allow access to data in our database to external consumers.  To provide this functionality, I used the NuSOAP library and PHP.  However, one of the limitations of the NuSOAP library is that it is unable to parse SOAP headers, which typically contain authentication information.  Consider:

<xmp>
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd">
 
<soap:Header>
<AuthenticationInfo xmlns="urn:MyService">
<username>test</username>
<password>1a232d4dg35</password>
</AuthenticationInfo>
</soap:Header>
<SOAP:Body>
<ns1:SomeMethod xmlns:ns1="urn:MyService">
<param1>foo</param1>
<param2>bar</param2>
</ns1:SomeMethod>
</SOAP:Body>
</SOAP-ENV:Envelope>
</xmp>

As you can see, the username and password are embedded in the SOAP:header.  So, to get at this data, you will need to parse the header yourself.  The way I chose to do this was to subclass the NuSOAP soap_server class and override the service method.

<xmp>
<?php
class MySoapServer extends soap_server
{
var $_objParser;
 
// Class constructor
function MySoapServer($wsdl=false)
{
// Create a new instance of the XML parser
$this->_objParser = new MyXMLParser();
 
// Call the parent constructor method and pass the WSDL flag to it
parent::soap_server($wsdl);
 
} // End Function
 
function service($data)
{
// Parse the xml message
$this->_objParser->setXMLData($data);
 
// Retrieve the authentication information from the xml message
$arrCredentials = $this->_objParser->getCredentials();
 
// Sanity check - did we get the credentials?
if(is_array($arrCredentials) &&
($arrCredentials['username'] != "") &&
($arrCredentials['password'] != ""))
{
// Authenticate the user
$this->_intWSUserID = $this->_authenticate($arrCredentials);
 
// If authentication was successful, handle the rest of the message
if($this->_intWSUserID > 0)
{
parent::service($data);
}
else
{
// return a SOAP fault
}
}
 
} // End Function
 
function _authenticate($arrCredentials)
{
// Sanity check: did we get a valid array?
if(! is_array($arrCredentials))
{
// return a SOAP fault
}
 
// Handle your authentication code here.  I use a MySQL database for holding user data
 
} // End Function
 
} // End of Class
?>
</xmp>

In this above example, I deal with a class called "MyXMLParser", which is an object that has methods for parsing XML data.  You could just as easily parse the data using native PHP methods.  As you can see, the AuthenticationInfo is parsed out of the SOAP message header, and the username and password are extracted and passed to the _authenticate() method.  How you choose to do your authentication is up to you.  In my case, I return the userID from the database for the authenticated user.  If and only if I get a userID back from the _authenticate() method do I call the service() method in the parent class.

Thanks to Scott Nichol for a great PHP library!

Technorati Tags: php nusoap SOAP

Loan Me $300

I admit it, I am a big fan of the show "Desperate Housewives" and I am not ashamed.  I mean, after all, I know it's like a soap opera in primetime, but the stories are well written, the acting is decent, the women are HOT, and the show is genuinely funny.

My only complaint is that the show is on ABC, which lately, seems to stand for "Always Broadcasting Commercials".  Let's be clear on one point - I HATE COMMERCIALS.  I have never once in my entire life seen a commercial and suddenly felt the urge to go out and spend money on that product.  Not once.  I can't stand the jingles.  I can't stand the cheesy humor.  And I really can't stand the constant interruptions to my favorite shows.

I watched the latest Desperate Housewives episode last night, and if you did too, you might have noticed that there is barely eight minutes of footage before the next round of commercials.  We had a commercial break at 9:30.  The show came back on at 9:32.  Another commercial break at 9:39.  The show came back on at 9:41.  Another commercial break at 9:48.  It's more than just invasive - it's downright disturbing because your brain and attention has to keep switching gears.  It's no wonder why we have such things as TiVo.

Which brings me to why I need $300.00.  I don't like TiVo either, and it's because as a company, they have to bow to the pressures of the networks.  You used to be able to skip commercials entirely.  Not anymore - TiVo and Comcast are jointly developing an advertising system that inserts up-to-date commercials into previously recorded programming. This whopper follows news that TiVo has begun testing a new advertising format that will appear as users fast forward through commercials on its digital video recorder service.  I am, however, a big fan of DIY-type PVRs.  Windows Media Center, MythTV, and Sage all offer the same functionality as a TiVO, but with true ad blocking.  The added benefit to building your own is that you are truly not restricted by the amount you can record.  Why should I have to settle for a 250GB or 400GB hard drive in a TiVo, when I can built a fileserver with a few terrabytes of storage that can be NFS mounted to my PVR?

I'd like to say that homebrew kits like these will cause the networks to wake up and change their evil ways, but I know better.  Instead, there will be a lot of congressional lobbying for boadcast flag support, anti-PVR legislation, and the criminalization of anything that records something else.

But hey, those corporate networks need all the money they can get so that they can continue producing such fine television fare as American Idol and Joey...

Al Qaeda Develops New Weapons of Mass Destruction

The CIA has learned today through anonymous sources and on-the-ground intelligence that Al Qaeda has developed new weapons of mass destruction, the likes of which have never been seen in this country. Sources tell us that Pakistani scientists have been working for decades on weather-related weapons, and have finally developed a working prototype that was recently tested by radicals in Pakistan.

The device (pictured at right) generates high currents of wind, which causes air molecules to rub together causing friction and lightning. Because the wind that is generated is rotational, it has the power to absorb moisture from large bodies of water, thus giving the weapon far more power than just pure air. Pakistani scientists predict high wind, coupled with flooding, lightning, and tornados.

The CIA and the Department of Homeland Security have identified Hurricane Katrina as the result of the first test run of this weapon. High winds generated from the machine originated over Pakistan where they were picked up by the jetstream and carried over Africa. From there, the wind hit conditions favorable for future development, and found a vast source of warm water - the Atlantic Ocean. As we have seen, this weapon brings mass destruction where it hits.

Sources are reporting that the President has been briefed, and has declared war against hurricanes, saying "The sole purpose of a hurricane is to terrorize the citizens of the United States, and they are weapons of mass destruction. We must prevail." However, our military presence in Afghanistan and Iraq, coupled with the National Guard activations to the Gulf Coast have left the US unable to respond with military force. "All options are on the table," declared the President.

Due to the unpredictable nature of these weapons, the CIA, NSA, and DHS have been unable to predict where future attacks might occur. The nation's terror alert status has been upgraded to red.

About Erich

Erich is a web developer and a native New Englander who is passionate about life, the universe, and everything.

He is currently a senior Drupal developer at Harvard University, working on the IQSS OpenScholar project.  Prior to joining the team at Harvard, he was the engineering manager at CommonPlaces e-Solutions, in Hampstead, NH, contributing as the lead engineer on the Greenopolis.com and Twolia.com.

Erich is active in the Drupal community, having contributed modules and patches to the community. He presented at DrupalCon in Szeged Hungary, and co-presented at DrupalCon 2009 in Washington, DC.

Erich lives in New Hampshire with his wife, two sons, and two weimaraners.  When not writing code, Erich enjoys landscaping and woodworking.

Faceted search

Categories

Content type

Project types

Artwork Type

Artwork Tags

Recent comments

Activity Stream

May 7, 2010

  • Twitter ebeyrent tweeted "Finishing up faceted search features via #apachesolr and #luceneapi for @openscholar. #drupal" 6:40am #
  • Twitter ebeyrent tweeted "@EricLondon Have a great trip!" 6:21am #

May 6, 2010

May 5, 2010

May 4, 2010

  • Twitter ebeyrent tweeted "RT @robertDouglass: Curious about what @openscholar is all about? http://is.gd/bUa66 Videos! That's what you get with Acquia's turn-key ..." 8:14pm #
  • Twitter ebeyrent tweeted "#nowlistening "Box" by @mindsetx" 4:01pm #
  • Twitter ebeyrent tweeted "My current project: @acquia @openscholar: Just announced new #Drupal Distribution for HigherEd w Harvard's IQSS: http://bit.ly/beAOUp" 4:00pm #
  • Twitter ebeyrent tweeted "Happy international Star Wars day. May the 4th be with you! #starwars" 11:38am #