I'm trying to use an Event Receiver on a List to create a Managed Path with Wildcard-inclusion in the parent WebApplication. I tried to handle it with the following code (reduced to show the idea)
SPSecurity.RunWithElevatedPrivileges(
() =>
{
using (var site = new SPSite(properties.SiteId))
{
var semester = new Semester(properties.ListItem);
var webApplication = site.WebApplication;
webApplication.Prefixes.Add(semester.UrlPart, SPPrefixType.WildcardInclusion);
webApplication.Update(true);
}
});
If the code comes to Prefixes.Add it will throw a SecurityException. The SharepointWebSite-Account is far away from least privilege at the moment (DB-Sysadmin, Local Admin, Farm Admin), but it refuses to perform my task.
I just tried to accomplish my Task with powershell logged on as the user in question - and it works - so the user privileges seem not to be the Problem.
For clearification: it's an asynchronous on ItemAdded Event-Receiver.
I found something in the logs, but as i said from Powershell it works with that user:
08/24/2012 13:46:16.80 w3wp.exe (0x13EC) 0x12C8 SharePoint Foundation Topology 7f7y High Adding a new WildcardInclusion site prefix with the path SoSe to the web application MiscWebApp. efa9c69b-9634-90de-f417-1b3bf5bf9325
08/24/2012 13:46:16.80 w3wp.exe (0x13EC) 0x12C8 SharePoint Foundation Topology 8dyu High The SPPersistedObject, SPWebApplication Name=MiscWebApp, could not be updated because the current user is not a Farm Administrator. efa9c69b-9634-90de-f417-1b3bf5bf9325
Can anybody help?

