When a Site event feature is activated I am trying to set some properties on the web application. My feature uses this value.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite site = properties.Feature.Parent as SPSite;
if (site != null)
{
SPWebApplication web = site.WebApplication;
web.Properties["test"] = "test";
web.Update();
}
});
}
This however is giving me the following errors in Event Viewer.
Log Name: Application Source: Microsoft-SharePoint Products-Web Content Management Date: 08/02/2012 11:06:53 Event ID: 7363 Task Category: Publishing Cache Level:
Critical Keywords: User: USER NAME Computer:
SERVER NAME Description: Object Cache: The super reader account utilized by the cache does not have sufficient permissions to SharePoint databases. To configure the account use the following command 'stsadm -o setproperty -propertyname portalsuperreaderaccount -propertyvalue account -url webappurl'. It should be configured to be an account that has Read access to the SharePoint databases. Additional Data: Current default super reader account: NT AUTHORITY\LOCAL SERVICE
followed by
Log Name: Application Source: Microsoft-SharePoint Products-SharePoint Foundation Date: 08/02/2012 11:07:08 Event ID: 6615 Task Category: Runtime Level: Error Keywords: User: NT AUTHORITY\IUSR Computer:
COMOUTER Description: Access denied.
Why am I getting an Access denied when I am running with RunWithElevatedPrivileges
?
Update
From @SPArchaeologist feedback but not taking hi sadvice I have tried to turn off RemoteAdministratorAccessDenied
. I have also removed RunWithElevatedPrivileges
as we don't think it is needed.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
var remoteAdministratorAccessDenied = SPWebService.ContentService.RemoteAdministratorAccessDenied;
if (SPWebService.ContentService.RemoteAdministratorAccessDenied == true)
{
SPWebService.ContentService.RemoteAdministratorAccessDenied = false;
SPWebService.ContentService.Update(true);
}
SPSite site = properties.Feature.Parent as SPSite;
if (site != null)
{
SPWebApplication web = site.WebApplication;
web.Properties["test"] = "test";
web.Update();
}
SPWebService.ContentService.RemoteAdministratorAccessDenied = remoteAdministratorAccessDenied;
SPWebService.ContentService.Update(true);
}
Still getting the same errors as before.
The scope of my feature is Site.
Update
web.update()
& SPWebService.ContentService.Update(true);
are giving the access denied.
RemoteAdministratorAccessDenied
and it was not working for me, only disable using powershell