Can you Elevate Permissions to create Web Application Setting

Dec 10, 2010 at 9:00 PM
When I run the following code using an elevated web property, I still receive access denied. Is this only going to work in a web part or application page when the user running the page is a Farm Administrator or can I use the token of 

SHAREPOINT\SYSTEM?

bag = configManager.GetPropertyBag(ConfigLevel.CurrentSPWebApplication);
configManager.SetInPropertyBag("MyApplications.CompanyName", 
                                                                    "Contoso", bag);
Coordinator
Dec 10, 2010 at 9:52 PM

This is a SharePoint security, and not something the p&p API enforces.  Writing to the Farm (and I believe the web application) level configuration can not be done from a content web.  It either needs to be done from central admin, or from a console/powershell script.  If you host the functionality in central admin, it should work.  This is consistent with the overall model that you can't change web app or farm level settings at the site collection level.

Another option if this is necessary is to used list backed configuration to save the settings.  There is an example of doing this in the guidance as a quick start.  This requires some customization.  Using this approach will let you centralize these settings in a list within the farm, and you can then use elevated privileges from other site collections to read and write to that list.

 

Dec 13, 2010 at 3:49 PM

ckeyser,

If editing at the web farm level is only allowed in central admin or feature activation, that would be consistent. However, the documentation could be clearer on this point.

Thanks,

Tom