Search WebmasterHub.net
 
 
 
 
 
 


Article: SharePoint: Show / Hide Content Based on Permissions

 
SharePoint: Show / Hide Content Based on Permissions
The SPSecurityTrimmedControl class in SharePoint allows content to be displayed based on criteria such as the permissions and the authentication status of the current user. When the class is used on a .aspx page or Master Page, content contained inside the tag will only display to users that match the criteria specified using a number of properties / members associated with the class. For Example, this allows different links to be displayed to anonymous users and users who are authenticated / logged in. You can also use this to display content for users based on a large number of base permissions available in SharePoint.

Some of the common base permissions that are used with the SPSecurityTrimmedControl class to customize the experience for users based on their permissions might include teh following:

ManageWeb - A user with this permission has full access to the current site in a site collection.

ManageLists - A user with this permission can add and remove lists on a site, as well as modify the settings of the lists and libraries.

ManagePermissions - A user with this permission level has access to manage the permissions for a site, list or list item depending on the context of the permission mask.

AddListItems, EditListItems, DeleteListItems - A user with these permission can add, edit or delete items in the current list.

There are many more base permissions that cover a range of actions that can be made on content and sites in SharePoint, which are listed in full here: SPBasePermissions.

To apply these base permissions to the SPSecurityTrimmedControl Class, the PermissionsString property can be used, which allows one or more to be specified separated by commas.

The following is an example where the content inside the tag will be displayed to only users with full permission on the current site:

<SharePoint:SPSecurityTrimmedControl
    ID="TrimmedContentExample1"
    PermissionsString="ManageWeb"
    PermissionContext="CurrentSite"
    runat="server">

    <div>This will be visible only to a user with full access to the current site. </div>

</SharePoint:SPSecurityTrimmedControl>

For a range of examples using the SPSecurityTrimmedControl class to show / hide content based on permissions, see the article SharePoint: Show or Hide Content based on Permissions. The tutorial demonstrates and explains a number of scenarios where the class can be used to control which users see the content contained within a SPSecurityTrimmedControl tag on a page in SharePoint.

The article SharePoint: Show or Hide Content based on Permissions also provides information and some example uses of the class by displaying a View All Site Content link on a Master Page only to users with full access to a site, or users with access to manage lists on the site.
Categories: SharePoint Tutorials | Tips and How Tos
Popularity:
 
Total Views:138
Published:October 11, 2011
 

Members Login
     
 
Username:
Password:
Free Registration
 
     
 
Mailing List
     
 
 
     
 
WebmasterHub.net Blog
 
WebmasterHub.net Resources
     
 
Tools
-Free SEO - Bulk Submit
Tips & Tutorials
-SEO Tips
 
     
Recommended:
 
Home