1

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." }- }- }

2
  • 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. Commented Jan 17, 2015 at 20:44
  • When checking currentUser permissions is there a difference between SCA rights and Full control, when checking the IsSiteAdmin field? If yes, what api do I need to check for full control?
    – dont-know
    Commented Apr 24, 2023 at 10:56

2 Answers 2

1

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.

4
  • The account is a Global Admin, I'm doing this from a console application. Is there any other way?
    – Webfort
    Commented Jan 17, 2015 at 11:53
  • 1
    I would of thought a Global Admin would have enough permissions to at least perform a check?
    – Webfort
    Commented Jan 17, 2015 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)." Commented Jun 4, 2015 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? Commented Jun 4, 2015 at 18:45
1

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 and acknowledge you have read our privacy policy.

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