Dec 152015
 
Share

The following code returns all SharePoint permissions groups and the respective members.
This uses JQuery 1.xx and SPServices.


// Add JQuery and SPServices references. //
<script type="text/javascript"  src="jquery1.11.js" ></script>
<script type="text/javascript" src="jquery.SPServices.js"></script>

<script>
// alert("Debug Check 1");
$(document).ready(function() {
// Function returns all Permissions Groups
$().SPServices({
                        operation: "GetGroupCollectionFromSite",
                        async: false,
                        completefunc: function (xData, Status) {
                                        $(xData.responseXML).find("Group").each(function() {
                                        // alert($(this).attr("Name"));
                                        getAllUsersFromGroup($(this).attr("Name"));
                                                                                           });
                                                               }
                });
 });
                             
                                                                       
// Function returns all users in respective Groups                                           
function getAllUsersFromGroup(groupName) {
// alert(groupName);
$().SPServices({
                       operation: "GetUserCollectionFromGroup",
                       groupName: groupName,
                       async: false,
                       completefunc: function (xDataUser, Status) {
                                       $(xDataUser.responseXML).find("User").each(function() {
                                       $('#GroupUsers').append("<tr><td>" + groupName + "</td><td>" + $(this).attr("Name") + "</td></tr>");
                                                                                              });
                                                                   }
                });
}
</script>

<!-- Table for Output -->
<table align="LEFT" id="GroupUsers">
<tbody>
<tr>
<tr><td>Group</td><td>Member</td></tr>
</tbody>
</table>