How to check registered user using javascript in sharepoint

I need to check if the registered user is an admin user or not an administrator using JavaScript in the sharepoint designer or in the content editor web part.

Can anyone suggest?

+6
source share
3 answers

You can use jQuery and SPServices to study the group the registered user belongs to, see my post here that explains the principle. In this case, it hides the element if the user belongs to a specific group.

+2
source

You can use the javascript HasRights function defined in SharePoints core.js , you just need to pass the lower (limit) permission mask, as well as the upper limit.

See the post on Checking permissions with Javascript in Sharepoint 2007 and a list of permission masks . Since you want to check if this is an administrator, you can try the ManageWeb permission ManageWeb : 0x0000000040000000


Edit: Another possibility does not use the HasRights function, and SPSecurityTrimmedControl simply sets the global Javascript variable. An example you can find here: SharePoint: Run JavaScript based on user rights / permissions . This, of course, means extra markup (and does not work in the content editor web part), but it does work.
+6
source

In the web part, after editing, you will see a field called the target audience. You can only add groups, so first put the user in the group.

-1
source

Source: https://habr.com/ru/post/905601/


All Articles