Posts

Showing posts with the label SPSecurityTrimmedControl

SPBasePermissions Usage With (Programmatic) and Without Code

In this post, I list some of the properties and methods that return a SPBasePermissions enum , and some methods that take SPBasePermissions as a parameter when checking if a user has certain rights on an object in SharePoint.  Later in the post I also explain how the permission masks with SPBasePermissions can be used to customise (show / hide ) content and custom UI actions / links without using code. Programmatic uses of SPBasePermissions to check for or set permissions on various objects in SharePoint The following are some of the more common components in SharePoint that can be used to get or set permissions, or check if certain permissions are effective for a user on the object. Get or set the Base Permissions for a Role Definition in a Web SPWeb.RoleDefinitions.BasePermissions Get the current or specified user’s effective SPBasePermissions on an object (SPWeb, SPList, SPListItem, etc.) Username passed as String to GetUserEffectivePermissions(): SPSite SPSi...

Permission Based Content in SharePoint (With Examples)

The examples in this tutorial demonstrate how to restrict certain content or controls on a page in SharePoint to specific users based on their permissions .  It can be applied to a Master Page, or directly to a .aspx page in SharePoint using SharePoint Designer.  Many options are available to configure exactly how and when the content should be displayed using the base permissions available in SharePoint with the SPSecurityTrimmedControl class. The complete list of base permissions that can be used with the class can be viewed on this page: SPBasePermissions .  It is also possible to show or hide content based on user authentication using the AuthenticationRestrictions property of the class, which may be useful if you want to display a different set of links depending on if a user has been authenticated or is anonymous. Below are some examples of base permissions that are more likely to be used to restrict content to specific users with the associated permi...