1

I have developed a number of application pages using visual studio 2010 and deployed them on SharePoint 2010.

All the pages have been extended from LayoutsPageBase.

Currently all the application pages are accessible by any authenticated users. However I would like to allow certain groups/permission to access these pages and disallow access for other groups/permissions.

My question:

How can I set the permissions for application pages to be accessible only by certain groups on the SharePoint level and on the code level?

Tim
  • 4,414
  • 4
  • 35
  • 49
Saifal Maluk
  • 121
  • 2
  • 5
  • 14

1 Answers1

10

Override a combination of these properties from LayoutsPageBase:

These properties are used by the CheckRights method to grant or deny access to an application page.

If you need something more specific than these properties offer, set RightsCheckModes to None and then write your own code that throws the following exception if the user should not have access:

SPUtility.HandleAccessDenied((Exception) new UnauthorizedAccessException());

Following the convention of the LayoutsPageBase class, this custom code should be called by your override of either the OnLoadComplete or OnPreInit events.

Rich Bennema
  • 10,295
  • 4
  • 37
  • 58
  • 1
    a full example on this would be very appreciated. – Luis Valencia Jan 23 '12 at 12:59
  • The properties and methods listed cover a number of scenarios. One example would not cover them all. If you are having trouble using these in your situation, I suggest asking a new question. – Rich Bennema Jan 26 '12 at 12:51