[英]How to verify the logged in user using Javascript in sharepoint
I need to check whether the logged in user is a administrator or non-admin user by using JavaScript in sharepoint designer or content editor webpart. 我需要通过在sharepoint设计器或内容编辑器webpart中使用JavaScript来检查登录用户是管理员还是非管理员用户。
Can anybody suggest? 谁有人建议?
You can use the HasRights
javascript function defined in SharePoints core.js
, you just have to pass the lower (limit) permission mask as well as the upper limit. 您可以使用SharePoints
core.js
定义的HasRights
javascript函数,您只需传递较低(限制)权限掩码以及上限。
See the post about Checking Permissions with Javascript in Sharepoint 2007 and the list of permission masks . 请参阅Sharepoint 2007中有关使用Javascript检查权限的帖子以及权限掩码列表 。 As you want to check whether it is an administrator you could try the
ManageWeb
permission mask: 0x0000000040000000
如果要检查它是否是管理员,可以尝试使用
ManageWeb
权限掩码: 0x0000000040000000
HasRights
function, but a SPSecurityTrimmedControl
to simply set a global Javascript variable.
HasRights
函数,而是使用SPSecurityTrimmedControl
来简单地设置全局Javascript变量。
An example you can find here: SharePoint: Run JavaScript based on user rights / permissions .
On the web part, after you edit it there is aa field called target audience. 在Web部件上,在您编辑它之后,有一个名为目标受众的字段。 You can only put groups here so put the user in group first.
您只能在此处放置组,因此请先将用户置于组中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.