I've hosted an WCF service in SharePoint 2010 (basicHttpBinding) using this tutorial. The assembly is deployed to the GAC and contains the WCF service and a timerjob. Both call the same method. The timerjob works successful.
But when I call the method of the WCF service, I get an exception, that it can't write a property in the SPFarm PropertyBag.
System.Security.SecurityException: Access denied.
at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate()
at Microsoft.SharePoint.Administration.SPFarm.Update()
at MyCompany.MyProduct.Business.Config.SetPropertyValue(IPropertyBag propertyBag, String propertyName, String value)
The Zone of the assembly that failed was:
MyComputer
I tried to call the method using the Farm Administrator account and tried to use SPSecurity.RunWithElevatedPrivileges, but to no success.
I checked WindowsIdentity.GetCurrent() inside and outside the elevated privileges block, outside it's the callers user and inside it's the user of the WebApplications AppPool.
So the AppPool user is correctly impersonated, but SharePoint 2010 "disallows modification ... to all objects inheriting from SPPersistedObject in the Microsoft.SharePoint.Administration namespace ... from content web applications"
The article says, there is a switch SPWebService.ContentService.RemoteAdministratorAccessDenied (namespace Microsoft.SharePoint.Administration) to get rid of this behaviour, but I can't rely on administrators to use this to get my solution running.
So I'm still without a solution