Tuesday, August 28, 2007

Comparing the Timer Classes in .NET

A few days ago, I ran into some issues with the timer that I was using in my Windows Service. As it turns out, not all timers in .NET are created equal. This article was able to give me some valuable insight that I was able to use to solve my problem.

Friday, August 17, 2007

How To: Disable Clear Type for Office 2007

It could be that I have something wrong with my eyes, but the ClearType fonts that Microsoft now uses for its new Office 2007 suite is incredibly painful to my eyes. If you would like to disable ClearType fonts in Office 2007 and/or have Office respect system settings, try the following:

  1. Start -> Run -> Regedt32
  2. Navigate to the following key:
  3. Add the following DWORD value:
  4. Set the value to 1
  5. Close RegEdit

That's it. Naturally, restart Office if it's already running, but you should notice that the Office 2007 suite now respects the system settings for font smoothing.

Friday, August 03, 2007

Programatically Add User to SharePoint 2007

There are a ton of articles out there detailing how to add a user to a SharePoint site; however, it's a struggle to find anything detailing how to perform the operation in a SharePoint 2007 environment.

private static void AddUser()
using (SPSite site = new SPSite("http://test1"))
ServerContext context = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);

if (!profileManager.UserExists("senfo"))
UserProfile profile = profileManager.CreateUserProfile("senfo");

profile[PropertyConstants.WorkEmail].Value = "me@myaddress.com";
Console.WriteLine("User already exists...");
catch (UserNotFoundException err)

It's important to note that if you're using multiple membership providers that this code will throw the following Exception "No mapping between account names and security IDs was done". To correct the issue, add "MembershipProviderName:" in front of the username. For example, "SqlMembershipProvider:senfo".