I have this code which is used to check if a user has permissions to access the site or not.

jQuery.support.cors = true; 
            webURL: sites[index],
            operation: "GetRolesAndPermissionsForCurrentUser",
            async: true,
            completefunc: function (xData, Status) {

                var userPerm = $(xData.responseXML).SPFilterNode("Permissions").attr("Value");
                var userP = userPerm > 206292717568; //206292717568 is returned for the 'limited view' mask (below view)

                if (userP) {
                    CreateTile(index, userTileIndex);

Right now this code does not work with cross domain requests (SharePoint Online) and I think if I use the REST API with SP.RequestExecutor then I can get it work.

Has anyone run into this issue before?



I have not run into that issue but I don't think there is a direct equivalent to that method. I've tried these calls individually but haven't put them together to get a complete view.

https://site.sharepoint.com/_api/web/RoleAssignments/ to list out all of the assignments to users or groups

If the user is not listed in there, you can see what groups the user belongs to https://site.sharepoint.com/_api/web/GetUserById(1)/groups/

If it is enough to know the RoleAssignment (such as Contribute, Design, Edit, etc) you would be finished. If instead you need the BasePermission then you'll need to use https://site.sharepoint.com/_api/web/RoleDefinitions/ and parse the BasePermissions property. It is bit masked enum that you'll have to convert to get each BasePermission.

One problem this will have is that it will not work unless the user is directly assigned to one of the SharePoint groups. If an AD group is used, you want be able to see the user listed directly in the assignments or groups.

| improve this answer | |

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.