最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to verify the logged in user using Javascript in sharepoint - Stack Overflow

programmeradmin1浏览0评论

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.

Can anybody suggest?

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.

Can anybody suggest?

Share Improve this question edited Jan 10, 2012 at 12:28 Srikanth asked Jan 10, 2012 at 10:00 SrikanthSrikanth 6833 gold badges16 silver badges23 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

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.

See the post about Checking Permissions with Javascript in Sharepoint 2007 and the list of permission masks. As you want to check whether it is an administrator you could try the ManageWeb permission mask: 0x0000000040000000


Edit: Another possibility is not using the HasRights function, but a SPSecurityTrimmedControl to simply set a global Javascript variable. An example you can find here: SharePoint: Run JavaScript based on user rights / permissions. This of course means extra markup (and doesn't work in a content editor webpart), but it does work.

You can use JQuery and SPServices to examine the group a logged in user belongs to, see my post here which explains the principle. In that case, it hides an element if a user belongs to a particular group.

On the web part, after you edit it there is a a field called target audience. You can only put groups here so put the user in group first.

发布评论

评论列表(0)

  1. 暂无评论