Get List of All SharePoint Sites (/Teams and /sites) where user has permission in Office 365

laxman 1 Reputation point
2021-05-18T11:22:47.743+00:00

Dear Community ,

We have 50000 Sites in my Tenant, would like to read all site collections /sub sites information where user is a member of.

we are looking API Based solutions.

We implemented the same use case in 2013 with search api but in Online it’s not working. Also, we checked Rest and Graph api options, but couldn't find any best solution.

Highly appreciate your suggestions or help.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,183 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,001 Reputation points
    2021-05-19T04:15:13.147+00:00

    Hi @laxman ,

    With Graph api, you can only get the groups that the user is a memeber of: https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http

    For Rest api, the scope is site, so you can only get the information of one site.

    The best way is using search api, sign in as that user, _api/search/query?querytext='contentclass:STS_Site contentclass:STS_Web' .The user would get a list of the site he could access to.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.