Here the objective is to control the behavior of SiteActions.We can hide these based on the current logged in user permissions.We can hide the control from all the users accept the SiteAdmin who is having SiteCollection Administrator rights.
For this we do not require any custom coding , Only thing is we have to modify the Master page. Modifying the default master page is not advisable ,so create your custom master page.For deploying master page as a feature in the site follow this link
Now follow these steps to hide SiteActions :
1) Open the custom master page in visual studio or notepad
2) Search for <SharePoint:SiteActions
3) Wrap this SiteActions control with
SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl" runat="server" PermissionsString="ManageSubwebs">
“<SharePoint:SiteActions>”
“<SharePoint:SiteActions>”
See the image below
Here we have to set certain parameters like “PermissionString”.This defines if the current logged in user is having this permissions set is able to view the “SiteAction” control. Since ManageWeb is the highest level of permission set ,so this will be available to SiteAdmin only.
To remove the control from Anonymous user use this
PermissionsString="BrowseDirectories"
We can also give the permission level in concatenated fashion also ..like comma(‘,’) way. These permissions work in ‘OR’ manner.
To view the SPBasePermission Enumeration follow this MSDN Link
Similarly we can control the behavior of other controls like ViewAll Site Content
For this find <SharePoint:SPLinkButton in the master pagee
This control is already wrapped in SharePoint:SPSecurityTrimmedControl and is having Permission string as “ViewFormPages”.So We can set the permission string here as well based on our requirement.
See the code below present in the master page.
<SharePoint:SPSecurityTrimmedControl runat="server" permissionsstring="ViewFormPages">
<SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server"
NavigateUrl="~site/_layouts/viewlsts.aspx" Text=""
AccessKey="" />
SharePoint:SPSecurityTrimmedControl>
So your Job is done.If you face any problem then do let me know.
Enjoy!!!
No comments:
Post a Comment