Friday, November 16, 2007

.Net Configuration & Group Policies

I have a .Net smart-client deployed in several countries and I want to change a value in the configuration file. One way I could do it would be by publishing an updated version with the configuration changes using ClickOnce but that's a bit overkill and risky to release a new version each time a configuration value changes. I could also imagine some fancy ways to get the value from a web service but if I'm getting info like the base web service URL from configuration, I'd fall in a chicken before egg dilemma.

A better alternative, when working in a single domain, is to use Group Policies (GPO). I've modified my smart-client to read from the registry the key corresponding to the GPO. That may sound old-school and with the coming of .Net we've been preached (a lot and rightly so) not to use the registry anymore and that ".config" files where the right way to do things.

Actually, using GPOs doesn't change the way we do things in .Net. It's still a great practice to save user settings in the ".config" files. But when you're managing an application distributed across geographically distributed domain and you feel that some specific settings could change, consider reading the setting from a GPO registry entry. That way before deploying your GPO-aware application, you can ask your friendly IT administrator to create a new GPO for you with your initial value, deploy your application. And when it's time to change the value, just open a ticket/email/call/wake up your IT dude and ask him to change the value.

I've found a good article on implementing GPO aware application on DevX: ASP.NET Configuration and Group Policy, Part 2: Creating and Using Group Policy-Aware Providers. Don't be put away from the title, it talks about ASP.Net but the basic idea works just fine in other type of applications. You also don't need to create a configuration provider and just write some code that fetches the registry value but that's up to you to choose.

No comments: