Wednesday, September 9, 2009

Windows Authentication in EPiServer Community and EPiServer Mail

Lately I have seen more and more of our partners using Windows Authentication in their EPiServer Community and EPiServer Mail solutions. I guess the reason is the products are being more and more used within an intranet environment, which is really cool.

However I have noticed that a lot of developers are having difficulties configuring this type of environment. I’m sad to say that the documentation about this type of setup is sparse at best – so I can’t blame the developers who comes asking for help. I decided to write this blog post instead of sending the same mail to everyone who needs help.

In an environment where you use Forms Authentication you are fine using the instructions in my previous post, EPiServer Community role and membership providers. But if you are using Windows Authentication the EPiServerCommonIntegrationProvider will not be able to do the syncing of the users and roles. The reason is because the ValidateUser(username, password) method in EPiServerCommonIntegrationProvider is not called, since the WindowsAuthentication ticket stores everything needed to validate the user. This causes the user to be authenticated, but not synchronized (Identity of the request is set, but the Name of the Identity is not present in the EPiServerCommon database).

The rescue is a HTTP Module that is part of the EPiServer Common. Simply add the following module to your list of HTTP Modules in the web.config:

<add name="EPiServerCommonWindowsAuthenticationIntegration" type="EPiServer.Common.Web.Authorization.IntegrationHttpModule, EPiServer.Common.Web.Authorization" preCondition="managedHandler" />

What this module will do, is to first make sure that there’s a MembershipUser for the current request. This object would originate from the configured MembershipProvider. If it is set, but there’s no user in EPiServer.Common, it will synchronize the user using EPiServer.Common.Web.Authorization.Integrator.SynchronizeUser(MembershipUser, Password, createNew).

(Remember to remove the preCondition="managedHandler" attribute if you're not using IIS7 – thanks Erik)

Hanselman’s Tool List Revisited

I’m constantly in the hunt for new tools and programs that can make life easier, not only as a programmer but for my everyday personal life as well. Since I’m a programmer on the .Net platform I follow Scott Hanselman’s blog (if you are .Net programmer you don’t follow his blog; head over to this address straight away). Every year Scott produces the “Ultimate Developer and Power Users Tool List for Windows”, this list is my golf mine for finding new tools and util programs to use.

If you haven’t read Scott’s post before, I suggest you to start out by doing that - Scott Hanselman's 2009 Ultimate Developer and Power Users Tool List for Windows – because this blog post is my reflection on that list.

First of all, kudos to Scott for compiling this awesome list! I have not tested out all the programs that he mentions, but some of them I would like to comment and I have a few additions.

  • The best text editor for the Windows platform is in my opinion Notepad++. I used UltraEdit before, but Notepad++ is just as good and at the same time for free! It’s an obvious choice for me.
  • Never heard of Evernote before I read Scott’s list. Now I’ve downloaded it and started to use it. Since I both use Mac and Windows I really love applications that work on both, and especially apps that sync with over the web as well. I really hope that this app can replace Onenote.
  • Dropbox is the app/service I use to store stuff in the cloud. It has a nice web interface, but also applications for both Mac and Windows – which I love. You get 2 GB for free and it’s really easy to use, just drop your files in the Dropbox folder on your machine and it’s synced to the cloud. Fantastic!
  • Since I’m a Mac user I also have to mention WMware Fusion, which is the best virtualization software for the Mac.
  • Again, since I’m a Mac user – Bootcamp, could it be better?!
  • Writing comments in code is boring, but it’s more fun with GhostDoc. GhostDoc is a plug-in to Visual Studio that generates comments for you. Use it as stubs for your comments. GhostDoc recently got acquired by SubMain – let’s hope that this only brings good to the application.
  • Lately I have switched to Google Chrome as my preferred browser just because is so lightning fast and because I just love the  “One box for everything” idea.