I am using a third party control for my application in SharePoint 2010 and I need to add entries in the web.config of the web application. Programmatically I have added the entries in the code and while executing the code below


I am getting Access Denied error.I have elevated the privileges before updating it. Could anypone provide a solution for this?


My first thought was that you need to check that the app. pool account has write permissions to the web.config file. But actually I believe this API creates a timer job that will run on each server in the farm which means that your app. pool account needs rights to access the config DB.

I would try giving your app pool a/c farm admin rights temporarily to test this. You will probably need to do an iisreset. If that works you know you are on the right track and can experiment with what permissions it actually needs. Without seeing your code and log files that's the best advice I can offer.

Useful blog post (old but still good).

| improve this answer | |

You're getting this error because updating the web config in this manner tries to open all web.config's on all web applications, including ones to which SPElevatedPrivileges won't have access to (because they'll be running under a different app pool identity).

Google (or Bing if you're that way inclined) around for other methods of using SPWebConfigModification.

Edit: Here's the MSDN article with some sample code: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebconfigmodification.aspx

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.