When viewing a group in SharePoint, you can view a list of all permissions of that group across the site collection by going to Settings\View Group Permissions. Here is what that would look like:
Today a colleague wanted to export this list to Excel to facilitate some testing. The problem is the page that comes up when you click Settings\View Group Permissions is a dialog and you can’t right click on it, or even select and copy/paste.
The trick is browse directly to the URL that serves the dialog above. Here are the steps:
- Get the group ID. The URL when viewing a group is of the format http://yourServer/_layouts/people.aspx?MembershipGroupId=25. 25 is the group ID.
- Browse to this page http://yourServer/_layouts/viewgrouppermissions.aspx?ID=25, and change the ID to the ID of the group you want to view.
- On the page that comes up, right click on the table and choose Export to Microsoft Excel (or whatever else you fancy).
Is there any way to achieve this through C# code, so getting the list of permissions through code ?
There is, but you will need to loop through all the webs in the site collection, and all the sub webs and lists.
The main classes you will be working with include SPRoleAssignment, SPRoleDefinition and SPPrincipal (parent class of SPUser and SPGroup).
All securable objects in SharePoint (i.e list, list item, web) have a RoleAssignments property, which is a collection of SPRoleAssignment objects. This property will be your starting point.
All securable objects also have a HasUniqueRoleAssignments property – which determines if the object is inheriting permissions from its parent.
Hope this helps.
the post looks quite old, but I have a similar question. Is there a way to find out all the folders in Sharepoint and members and their permissions. what are highlevel steps?
Please let me know..
The method Bernado sets out will export the entire User List in SharePoint 2013 — at least, it does so in my environment. Here’s how I solved it:
I was able to pull the membership of a 2013 SharePoint permission group that had 2035 members using the following steps. Note that I wanted the account name only. You may need to modify this process slightly if you want a different field, or more than one field:
1. Page through the group to find out how many members it has
2. Go to Settings/Site Settings/People and Groups/ and choose any group.
3. Choose Settings/List Settings on the toolbar for the group membership
4. Create a new view with the column you want to export (I only wanted the account column), and set the Item limit to a few more than the number of members in the group you want to export (I set mine to show records in batches of 2100, then I called my view “2100 Items”)
5. Go back to Settings/Site Settings/People and Groups/ and choose the group you want to export.
6. At the right end of the toolbar for the group membership, change the view selector to select your custom view.
7. Use Ctrl/A to select the entire page, then Ctrl/C to copy it.
8. Open an empty text file using Notepad and paste the contents of the page into it.
9. The copy operation will leave you at the bottom of the text file. Delete all the text below the last account.
10. Go to the top of the text file and delete all the text above the first account.
You now have a fairly clean list of all the group members. Note that it contains a trailing space at the end of each line. Depending on how you want to use the data, you may need to do some more cleanup in Word or Excel. (Cleanup hints: You can paste your list of accounts into Excel, then use Text to Columns to clean off the trailing space. Or, you can use Word and replace all occurrences of [space][paragraph mark] with just [paragraph mark] if you exported multiple columns.)