none
Check user permission level using jquery/javascript RRS feed

  • Question

  • On a sharepoint page I need to check permission level for a user and based on permission level he is having i need to hide few elements on that page.any pointers on how to check user permission level using jquery/javascript.
    for eg: i need to do something like this
    if(userpermissionlevel=="custom read"){//hide some elements}
    Any pointers will be helpful.
    Friday, April 4, 2014 6:53 AM

Answers

  • Try below

    function checkifUserHasEditPermissions() { context = new SP.ClientContext.get_current(); web = context.get_web(); this._currentUser = web.get_currentUser(); context.load(this._currentUser); context.load(web,'EffectiveBasePermissions'); context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod)); } function onSuccessMethod(sender, args) { if (web.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems)) { //User Has Edit Permissions } }}

    http://social.technet.microsoft.com/Forums/sharepoint/en-US/f21ad6b1-445a-497d-a286-d3ba8c2928a6/how-to-get-the-current-user-permission-level-on-a-list-item-with-ecmascript

    or

    http://stackoverflow.com/questions/22122139/check-if-current-users-belongs-to-sp-group-using-javascript-client-side-object-m

    http://blog.fidelityfactory.com/2011/11/29/sharepoint-client-ecma-script-check-user-permissions/



    • Marked as answer by JasonGuo Sunday, April 13, 2014 3:18 PM
    Friday, April 4, 2014 7:05 AM
    Moderator
  • Hi,

    Please find some related threads,

    https://spservices.codeplex.com/discussions/80847

    may be it will help you


    Thanks
    Jaison A
    http://infomoss.blogspot.in


    • Edited by Jaison Arumugam Friday, April 4, 2014 7:14 AM
    • Marked as answer by JasonGuo Sunday, April 13, 2014 3:18 PM
    Friday, April 4, 2014 7:11 AM

All replies

  • Try below

    function checkifUserHasEditPermissions() { context = new SP.ClientContext.get_current(); web = context.get_web(); this._currentUser = web.get_currentUser(); context.load(this._currentUser); context.load(web,'EffectiveBasePermissions'); context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod)); } function onSuccessMethod(sender, args) { if (web.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems)) { //User Has Edit Permissions } }}

    http://social.technet.microsoft.com/Forums/sharepoint/en-US/f21ad6b1-445a-497d-a286-d3ba8c2928a6/how-to-get-the-current-user-permission-level-on-a-list-item-with-ecmascript

    or

    http://stackoverflow.com/questions/22122139/check-if-current-users-belongs-to-sp-group-using-javascript-client-side-object-m

    http://blog.fidelityfactory.com/2011/11/29/sharepoint-client-ecma-script-check-user-permissions/



    • Marked as answer by JasonGuo Sunday, April 13, 2014 3:18 PM
    Friday, April 4, 2014 7:05 AM
    Moderator
  • Hi,

    Please find some related threads,

    https://spservices.codeplex.com/discussions/80847

    may be it will help you


    Thanks
    Jaison A
    http://infomoss.blogspot.in


    • Edited by Jaison Arumugam Friday, April 4, 2014 7:14 AM
    • Marked as answer by JasonGuo Sunday, April 13, 2014 3:18 PM
    Friday, April 4, 2014 7:11 AM