Is there away to check if a user has Full Control permissions with out throwing an exception? I've tried the following using REST:

https://tenant.sharepoint.com/sites/test/_api/web/doesuserhavepermissions(@v)?@v={'High':'2147483647', 'Low':'4294967295'}

I get the following:

{ error: { code: "-2147024891, System.UnauthorizedAccessException" message: { lang: "en-US" value: "Access denied. You do not have permission to perform this action or access this resource." }- }- }

  • You mention below in a comment that you are doing this via a console application. What method are you using to connect to the server? Make sure you are sending valid credentials with that request. – ErinsMatthew Jan 17 '15 at 20:44

If the current user has not enough permission then you won't be able to check the permission itself.

The best option is to run the permission check in APP context.

  • The account is a Global Admin, I'm doing this from a console application. Is there any other way? – Webfort Jan 17 '15 at 11:53
  • 1
    I would of thought a Global Admin would have enough permissions to at least perform a check? – Webfort Jan 17 '15 at 12:12
  • What kind of App Authorization Policy are you using, do you know? If you're making the request from an App-only policy, "Authorization check succeeds only if the current app has sufficient permissions to perform the action in question, regardless of the permissions of the current user (if any)." – Danny Bullis Jun 4 '15 at 18:42
  • @AmalHashim, can you expand on what you mean by "run the permission check in APP context"? Perhaps some code would be helpful? – Danny Bullis Jun 4 '15 at 18:45

If user is Global admin then you can check user permission programmatically:

SPUser currentUser = null;
using (SPSite spSite = SPContext.Current.Site)
    using (SPWeb web = spSite.OpenWeb())
        currentUser = web.CurrentUser;                        
        bool isSiteAdmin = currentUser.IsSiteAdmin;
        if (isSiteAdmin)
            Console.WriteLine(currentUser + " has Full Control.");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.