Monday, October 31, 2011

National Novel Writing Month

It seems that most people I know aspire to write a Novel at some point, including me. Writing is a lofty profession and a book or novel is a path to immortality. How many people today know of Jane Austen, Ernest Hemingway, Mark Twain, and Charles Dickens? These writers have achieved a sort of immortality through their writing, as they have written books that even today we read and analyze.

That is why when I found that November is National Novel Writing Month, I signed up to participate. The goal of the site is to write a short novel of about 190 pages within 30 days. While I'm no R.L. Stine or Stephen King, I still think a short novel can still be written in a short time. I'll know for certain in 30 days.

To foster my writing, I've drawn up a short outline of the novel that I'm going to write. It's based on some of my and my wife's encounters while living in a small town in Southern Indiana while I was going to college. Its one of a few stories that I've had bouncing around my head for the last few years. A National Novel Writing Month is just what I need to get one of the stories out of my head.

Writing a novel in a month on top of a busy work schedule will be a trick. In order to facilitate this, I've decided to write the novel in Google Docs, so I will have access to the novel from my laptop, either of my desktop computers, and my phone. I've used Google Docs for some writing before, but never for something as long or complex as a novel. It should prove as a good test to see just how far Web applications have advanced.

Do you have a few story ideas bouncing around your head? Would a National Novel Writing Month help to transfer those ideas to paper?

Thursday, October 20, 2011

Strengths vs. Weaknesses

On the recommendation of the Startupsfor the Rest of Us podcast#38, I just read Strengths Finder 2.0. From a book that came highly recommended by others, I was a bit disappointed in the book, the test that accompanies it, as well as the test results that are provided after the test has been complete. If you can find the book at a reasonable price like I did, I still think you'll get your money's worth.

The book provides an introduction to the test and the 34 'themes' that the test can identify. The introduction explains the importance focusing on ones strengths by using a few analogies, yet most of these analogies involve sports. A personality test like the one that is included with the book of course would never work for an aptitude with sports. While sports analogies are easily accessible, with access to numerous individuals who have taken their personality test, one would imagine a more appropriate analogy would be available.

The test itself involved a series of two statements which one must judge which applies better. However, the nature of the test and the speed of which it must be finished (as each question has a set time period in which it must be answered), made me extremely nervous and had me second guessing myself. While I'm a very introspective person by nature, I also second guess myself as to whether I'm the best judge of my character or if my wife would have been able to answer more accurately.

Finally, I think it would have been helpful if the test results would have also revealed 5 weaknesses, so I could know what areas to avoid. However, with the description of the 'themes' in the book, I can identify which areas I'm weakest at myself, though it would have been nice to know this from the test.

While my review of this book has been harshly critical, I think there's a couple points to keep in mind. First, this book came highly recommended, so I had high expectations going in. Second, the book and test are a few years old, and as such, I think there are likely better personality tests out there now. The book touted itself as a revolutionary way to determine strengths, but in the end, it seemed like a standard personality test, one that I've taken for free on the internet every now and again. Having to pay $10 to $15 for the book to gain access to the test is a little steep. However, if you can find this book for less, I would say it would be a good deal and worth the couple of hours it would take to read the book and take the test.


Tuesday, September 27, 2011

User Impersonation in .NET

Recently, I've been working on a tool to manage deployments to a web farm. As part of this task, I had to modify our current tool to impersonate a shared login to perform the actions on the various servers. This was so the IT group would not have to grant access to a large number of users. This can be done in .NET, but the approach you have to take to impersonate another user is different depending on the action you are taking. While updating the program, I encountered three scenarios which had to be addressed in different ways.

Scenario #1: Executing .NET code in the current Thread
Scenario #2: Spawning a new Process in .NET
Scenario #3: Making a WMI request

Scenario #1: Executing .NET code in the current Thread
Executing .NET code as a different user may be necessary when performing disk operations, network operations, manipulating services, or other tasks that require security permissions. To start the Impersonation, the WindowsIdentity.Impersonate() method needs to be called with an authorization token for the impersonated user. This entire process requires making an external call to the Windows API to authenticate the user. While it sounds difficult, the MSDN page for the Impersonate() method provides a working sample that can be used as a basis for your own code.

Scenario #2: Spawning a new Process in .NET
Creating a new process already requires setting up a Process object or a ProcessStartInfo object. To set this object to execute as a different user requires just a bit of extra work to pass in a username and password. The following code snippet shows how to create a ProcessStartInfo object to start the command prompt as an Impersonated user.



String userName;
SecureString password;

// Code to get and set userName and password.

ProcessStartInfo startInfo = new ProcessStartInfo(“cmd.exe”);
startInfo.UserName = userName;
startInfo.Password = password;
// Add other parameters to startInfo as needed
Process.Start(startInfo);


Scenario #3: Making a WMI request
A WMI request queries the current or a remote server for system information to monitor the system. This functionality resides in the System.Management namespace, and isn't a common one to work with. WMI does allow for the queries to be ran as another user by creating a ConnectionOptions object, as the below example outlines.



String userName;
SecureString password;

// Code to get and set userName and password.

ConnectionOptions connectOptions = new ConnectionOptions();
options.UserName = userName;
options.Password = password;

ManagementPath path = new ManagementPath(“path to wmi object to query”);
ManagementScope scope = new ManagementScope(path, connectOptions);

// Once we have a scope object, we can either create an ObjectQuery object and query that way
scope.Connect();

ObjectQuery query = new ObjectQuery(“query to execute”);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection collection = searcher.Get();

// Or we can create an ObjectGetOptions and a ManagementObject
ObjectGetOptions options = new ObjectGetOptions();
ManagementObject mgmtObject = new ManagementObject(scope, path, options);
mgmtObject.Get();
// Can now retrieve values from ManagementObject like a Dictionary
string value = mgmtObject[“key name”].ToString();