Lars Nielsen's Discoveries

May 14, 2010

Using SPWebModification to modify the web.config (Part 7)

Filed under: Development,SharePoint,Troubleshooting — Lars Nielsen @ 8:00 pm
Tags: ,

This is one of a series of posts – start here to read the whole series

Deployment Issues

Initially, as I mentioned in the previous post, I tried creating the feature scoped to a site collection, but I had a tricky issue when trying to update the web.config file from within the feature receiver of a site collection.

When I had the feature scoped to a web application feature, it worked with no problems at all.  When I switched to using a site collection, it worked OK on my dev environment where everything is running on full privileges.  But I started to get problems when I deployed the solution onto our production environment which is more locked down with all the appropriate domain accounts.

Initally I was getting an exception when trying to activate the feature:

The EXECUTE permission was denied on the object ‘proc_putObject’, database ‘SharePoint_Config’, schema ‘dbo’

This error appears to be an issue with the permissions to the SharePoint configuration database.  The general recommendation I found was to ensure that the application pool identity of the web application has sufficient permissions on the config database.  I was reluctant to do this anyway as it would mean making modifications directly to the SharePoint databases which is generally not a good idea.  But I thought it wouldn’t do any harm to look. So I went into SQL Server Management Studio and had a look at the security settings for the SharePoint config database, but everything seemed to be fine.

Eventually I found this blog  post by Vince Rothwell which gave me a clue.  I followed his advice and switched the application pool that the site collection was running in to be the same as Central Admin, then activate the feature, and then switch the application pool back again.  This did work but it’s obviously quite disruptive to do this in a production environment – I ended up having to reset IIS on the server after switching the application pool back.

So for now I use this feature at web application scope where it doesn’t cause any problems like this.  To activate or deactivate the feature, you go to Central Administration, click Applications and Manage Web Application Features.  Pick the web application whose web.config you want to modify, and click the button.

Conclusion

That’s the end of the series.  There’s a whole load of great information about using SPWebModification out there.  I found the following really useful – definitely worth a read:

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: