<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2"runat="server" PermissionsString="AddAndCustomizePages">
如果符合PermissionsString限制的权限要求,那么本内容会输出显示,否则不输出。
</Sharepoint:SPSecurityTrimmedControl>
通过使用上面的权限判断控件,可以根据当前用户权限做一些控制,例如如果用户没有编辑页面,那么不显示ribbon
1) Open your SharePoint master page
2) Locate this line:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle">
3) Change it to:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle"style="display:none">
4) Now find the end of the “s4-ribbonrow” tag and add following block right after it:
<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2"runat="server" PermissionsString="AddAndCustomizePages">
<script type="text/javascript">
document.getElementById("s4-ribbonrow").style.display = "block";
</script>
</Sharepoint:SPSecurityTrimmedControl>
5) Save the new master page and publish it.
下面是可以填入的PermissionString值,根据名字已经大概知道用法了。
PermissionString. The available options include:
- List Permissions
- ManageLists
- CancelCheckout
- AddListItems
- EditListItems
- DeleteListItems
- ViewListItems
- ApproveItems
- OpenItems
- ViewVersions
- DeleteVersions
- CreateAlerts
- ViewFormPages
- Site Permissions
- ManagePermissions
- ViewUsageData
- ManageSubwebs
- ManageWeb
- AddAndCustomizePages
- ApplyThemeAndBorder
- ApplyStyleSheets
- CreateGroups
- BrowseDirectories
- CreateSSCSite
- ViewPages
- EnumeratePermissions
- BrowseUserInfo
- ManageAlerts
- UseRemoteAPIs
- UseClientIntegration
- Open
- EditMyUserInfo
- Personal Permissions
- ManagePersonalViews
- AddDelPrivateWebParts
- UpdatePersonalWebParts
以上的内容参考自: