Has anybody have the awareness about to getting all the users from all the site and sub sites. I want to create a access report that will describes each users permission in each and every site and sub site in sharepoint. I am getting all the site and subsites. and i can take the users from each site. But i wish to know that is there any way to get all users firstly and then they involved sites. and what are the permission for each users in that sites.

3 Answers 3


This is a painful task to achieve because you have to iterate for each site and get user and permission.

You could use something like this

SPSite siteCollection = new SPSite("site url");
SPWeb site = siteCollection.OpenWeb();

foreach(SPGroup group in site.Groups)
  foreach(SPUser u in group.Users)
     //will give you users in group, you can then grab the roles of the user
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name"])
  SPMember oMember = oWebsite.Roles["Role_Name"];
  oWebsite.Permissions[oMember].PermissionMask = //permission to check;

You can always use PowerShell to list all users:

$site = Get-SPSite http://yourservername/sites/yoursitecollection 

$groups = $site.RootWeb.sitegroups

foreach ($grp in $groups) 
    "Group: " + $grp.name; 
    foreach ($user in $grp.users) 
        "  User: " + $user.name


And when you have all the users, you can use Sharepoint SP2010 - Retrieve all User Permissions via Powershell available on Codeplex.

  • Note the 2007 tag on question. I think using PS is not an option Commented Apr 18, 2013 at 8:32

I would recommend you using powershell. First, Iterate through all available sites (web) and then just iterate through all users on this site and write to console/file username and his permission to this web. You can also go further and display permissions to specific list on this site. This is imho the easiest approach.

However, if you want different view - list users and to users list all their sites they have permission on, it would need different approach to store date but the idea should be the same.

EDIT: just a little googling and I've found script that should suit your needs:


  • Note the 2007 tag on question. I think using PS is not an option Commented Apr 18, 2013 at 8:34
  • Didn't see that. In that case he can create console app and rewrite PS code to .NET, shouldn't be so hard.
    – luccio
    Commented Apr 18, 2013 at 8:36

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.