Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

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)
{
  Console.WriteLine(group.Name);
  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;
}
share|improve this answer
add comment

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
    } 
}

$site.Dispose()

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

share|improve this answer
    
Note the 2007 tag on question. I think using PS is not an option –  Vedran Rasol Apr 18 '13 at 8:32
add comment

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:

https://sp2010userperm.codeplex.com/

share|improve this answer
    
Note the 2007 tag on question. I think using PS is not an option –  Vedran Rasol Apr 18 '13 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 Apr 18 '13 at 8:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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