Skip to content

Instantly share code, notes, and snippets.

@umbraesoulsbane
Created July 6, 2012 16:18
Show Gist options
  • Save umbraesoulsbane/3061132 to your computer and use it in GitHub Desktop.
Save umbraesoulsbane/3061132 to your computer and use it in GitHub Desktop.
AccessRequest Event Reciever
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;
namespace AccessRequest.Features.AccessRequestFeature
{
[Guid("c7482d83-8a04-4aa0-95e6-bf629805ecb1")]
public class CSXAccessRequestFeatureEventReceiver : SPFeatureReceiver
{
const string customRequestAccessPage = "/_layouts/AccessRequest/ReqAcc.aspx";
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
if (null != webApp)
{
if (webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.RequestAccess, customRequestAccessPage))
{
webApp.Update();
}
}
});
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
if (null != webApp)
{
if (webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.RequestAccess, null))
{
webApp.Update();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment