2

How to get all users of office 365 and their permissions in SharePoint hosted app and is it even possible ?

I want to get everyone's permissions and display content based on permissions of current user.

2
  • Isn't the content already security trimmed based on users permissions? Commented Jan 22, 2015 at 13:01
  • @AmalHashim Nope - not the app content Commented Jan 22, 2015 at 13:07

1 Answer 1

0

In a new page, with SPServices you can get the current users groups. You could make a list that has the groups and the features that group has access to, then filter the list based on the groups the current user matches to. All done client side using javascript/jquery.

<script type="text/javascript" src="../../SiteAssets/jquery/jquery1-11/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../../SiteAssets/jquery/SPServices/jquery.SPServices-2014.01.min.js"></script>

<script type="text/javascript">
    $(document).ready(function() {  

        //Global Variables
        thisUserAccount = $().SPServices.SPGetCurrentUser({
            fieldName: "Name",
            debug: false
        });

        groupArray = new Array(); 



        $().SPServices({ 
          operation: "GetGroupCollectionFromUser", 
                userLoginName: $().SPServices.SPGetCurrentUser(), 
                async: false, 
                completefunc: function(xData, Status){
                    $(xData.responseXML).find("Group").each(function(){         
                        groupArray.push($(this).attr("Name"));      
                    });
                }
         }); 
});
</script>

Putting this in document ready will give you an array with the current user's groups. From there you could query the list with groups and features that work for those groups (you would have to build and maintain this). Using SPServices GetListItems you can print to the page the groups and features that match what is in the array.

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.