I was asked today by a friend, How do you modify the web.config through a WSP? My quick answer, I don’t! Not if I can avoid it other than the changes made through Visual Studio item properties like safe controls entries and others. However, showing my true consultant nature, I turned the question into the above. That’s a more specific question with a couple good possibilities I’d like to share, but still, it seems like there may be better answers I haven’t found. How do YOU automate FBA web.config changes? If you don’t use one of the options below, let me know in the comments or at http://twitter.com/resing
First, the Manual Way
After going through the Microsoft Certified Master training, I consider Steve Peshka’s writing on FBA to be the go to source. Read Configuring Forms Based Authentication in SharePoint 2010 for the step by step. Basically, Steve outlines the manual processes you need to take. But what if you have 100s of servers to apply the changes to and need to maintain consistency? Scripting is the key in my mind
Taking some of the manual processes Steve describes to script, like creating web applications with the correct properties are already covered by others on the web. However, updating web.config is a bigger issue. And it’s a necessary script. When we say “NEVER TOUCH THE WEB.CONFIG BY HAND” it always comes with a disclaimer for cases like FBA. You kind of have to. However, Steve also provides an automated approach.
2 Forms Based Authentication Configuration Managers
I haven’t tried out either of these 2 options, but I feel comfortable recommended you at least check them out based on the source (Steve) and the source (codeplex.)
First, Steve had produced what he calls the SharePoint 2010 Forms Based Authentication Configuration Manager. He explains it in his blog post and provides a readme file in the download. It uses primary SharePoint concepts like a Solution Package, .wsp, and timer jobs to make the changes. Seems very reasonable.
Second, there is another project, this one on codeplex, based on the same manual techniques. The author explains his approach in a post on his blog, FBA Configuration Manager for SharePoint 2010. What I like about this solution is two things. 1, the code is available on codeplex, so you can explore the technique used and tweak it if you want. 2, it uses PowerShell. I’m a big fan of PowerShell, so I think that is just cool.
The Custom Code Way
If neither of those approaches work for you or you are just the type to write your own code and live on the edge, read What every SharePoint developer should know about the web.config file. The author does a good job of explaining the code options and some of the many issues with it. Honestly, I recommend against this method. This method I have tried before and run into some major issues. I don’t trust it. And if you can’t trust it, it won’t achieve the desired result of consistency. However, under the perfect conditions, this may work for you and some people seem to like it, so I mention it. However, be wary.
One of the things I love most about sharing with the SharePoint community is the great feedback I get. If you’ve used one of the methods above or have a better way, please let me know! I’ll be sure to update this post with your solution if it can help the community.
Leave a Reply