I want to retrieve all Groups a specific user is member of. But it should include all Site Collections and in the best case also all Webapplications. If there are two groups in different Site Collections with the same name, that they should be listed twice.

The System is a SP2013 on premise installation.

I think that the Groups property of a user only returns the ones of the SiteCollection? Right?

Is there a better way than iterating all SiteCollections->Webs and so forth?


  • Do you consider a user to be member of a SharePoint group, if he is member of an Active Directory group that is member of the group, or you need only the direct memberships?
    – pholpar
    Commented Feb 20, 2015 at 9:11
  • Hi, i just need the direct membership. I want to know which groups a User with an Unique ID,Loginname,etc... is member of
    – AdelPoint
    Commented Feb 20, 2015 at 9:16

2 Answers 2


The official and supported solution is to iterate through all the web applications in the farm and then through all site collections in the given web application. For example, using PowerShell:

$loginName = "domain\user"
Get-SPWebApplication | % { $_.Sites | % { $_.Url; $_.RootWeb.AllUsers | ? { $_.UserLogin -eq $loginName } | % { $_.Groups } | % { $_.Name } } }

Using an SQL query from the content DB (must be repeated on all content DBs in the farm!), the unsupported (!) way:

FROM GroupMembership GM
INNER JOIN UserInfo U ON GM.MemberId = U.tp_ID
INNER JOIN Groups G ON GM.GroupId = G.ID
WHERE U.tp_Login = 'domain\user'
  • Puh, I really hoped there was a better solution for this, but thanks! I can only use the supported ways so I will iterate the webapps and sitecollections and so forth...
    – AdelPoint
    Commented Feb 20, 2015 at 9:48
  • Ok, one question though: How would I do the same thing in SharePoint Online? Do I also need to iterate over all tentant site collections and webs?
    – AdelPoint
    Commented Feb 23, 2015 at 11:38
  • I don't know any other official solution. The SQL query is for sure no way in SPO.
    – pholpar
    Commented Feb 23, 2015 at 12:42

Did you check SharePoint 2013 Permission Report: Check Access Rights for a Specific User. I think this report in PowerShell can help.

This are the parameters:

Generate-PermissionReport $Userid $WebAppURL $ReportPath

You can iterate web applications to call the report. Hope it will be helpfully.

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.