Set Permissions on SharePoint Application Pages
I have developed a number of application pages using visual studio 2010 and deployed them on SharePoint 2010.
All the page开发者_Python百科s 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?
Override a combination of these properties from LayoutsPageBase:
- RequireDefaultLayoutsRights
- RequireSiteAdministrator
- RightsRequired
- SupportsReadOnlySite
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.
精彩评论