当激活网站功能时, 我自动要设置 WebApplication 属性。 这是代码 :
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb currentWeb = ContentTypes.ValidateFeatureActivation(properties);
using (SPSite site = new SPSite(currentWeb.Site.Url))
{
SPWebApplication currentApplication = site.WebApplication;
if (currentApplication.MaxQueryLookupFields < 20)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
try
{
currentApplication.MaxQueryLookupFields = 20;
}
catch (System.Security.SecurityException ex)
{
_log.ErrorFormat("no permission");
}
});
}
}
}
即使我有一个农场管理员激活了这个功能, 安全例外也会被抛出(“拒绝进入” ) 。
currentApplication.MaxQueryLookupFields = 20;
AFAIK SP Security. Run with the Leveled Privitees 运行作为一个网站管理者, 农场管理者是“ 强势的” / 强势的。 但如何做到这一点呢? (WITHOUT run On with the leveled Privites I gets 相同例外 ) 。