我正在使用 SPWebConfigModification 类进行一些 web.config 修改。将它们添加到 WebApplication 并向其调用 Update 时,它会抛出 SecurityException,尽管
- 我以提升的权限运行代码(并打开 SPSite 的新实例)
- 我的程序集在 GAC
- 应用程序池帐户来自 wss_admin_wpg组,并且 web.config 文件具有wss_admin_wpg写入权限。
代码
SPSecurity.RunWithElevatedPrivileges(delegate()
{
addProviderProxy(properties);
});
其中 addProviderProxy(SPItemEventProperties 属性)
using (SPSite site = new SPSite(properties.SiteId))
using (SPWeb web = site.OpenWeb())
{
ensureSectionGroup(web);
...
}
其中 ensureSectionGroup(SPWeb web)
SPWebApplication webApp = web.Site.WebApplication;
...
webApp.Update(); <--Throws exception here
异常详情
System.Security.SecurityException was caught
Message="Piekļuve liegta." //(Translates to something like "Access Denied")
Source="Microsoft.SharePoint"
StackTrace:
at Microsoft.SharePoint.Administration.SPPersistedObject.Update()
at Microsoft.SharePoint.Administration.SPWebApplication.Update()
at Balticovo.SharePoint.AdjustWebConfigForOutlook.ensureSectionGroup(SPWeb web)
InnerException: