When working with intranet or extranet sites, as well as public-facing sites that allow users to log in, it is common to only allow administrators of the SharePoint site to see certain content. In this recipe, we will use our customized master page to hide content from users who are not site administrators.
Follow these steps to display specific content only to site:
seattle.master
(for our example, we have renamed it as Seattle_DisplayAdministratorContent.master
).Seattle_DisplayAdministratorContent.master
master page.Seattle_DisplayAdministratorContent.master
master page.ID_SuiteBarBrandingDelegate
ID.<SharePoint:SPSecurityTrimmedControl>
control with the following content:<SharePoint:SPSecurityTrimmedControl ID="customSecurityTrimmedControl" PermissionContext="CurrentSite" PermissionsString="ManageWeb" runat="server"> <span style="color: #FFFFFF; float: right;">Only Admins Can See This</span> </SharePoint:SPSecurityTrimmedControl>
The SPSecurityTrimmedControl
is a simple server control that displays its content based on the permission levels of the current user. When this control renders, it simply looks to the current SharePoint context to determine if the current user has the permission level required.
18.221.66.185