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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With