Created
July 6, 2012 16:18
-
-
Save umbraesoulsbane/3061132 to your computer and use it in GitHub Desktop.
AccessRequest Event Reciever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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