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.

  • Isn't the content already security trimmed based on users permissions? – Amal Hashim Jan 22 '15 at 13:01
  • @AmalHashim Nope - not the app content – Mathematics Jan 22 '15 at 13:07
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, privacy policy and cookie policy

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