Office 365 - Retrieve all sites a user has access to

%3CLINGO-SUB%20id%3D%22lingo-sub-214733%22%20slang%3D%22en-US%22%3EOffice%20365%20-%20Retrieve%20all%20sites%20a%20user%20has%20access%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-214733%22%20slang%3D%22en-US%22%3EWhat%20is%20the%20best%20way%20to%20retrieve%20all%20sites%20a%20user%20has%20access%20to%20in%20Office%20365%20using%20a%20script%20that%20runs%20outside%20Office%20365%20and%20how%20do%20we%20simulate%20user%20authentication%20%3F%3CBR%20%2F%3E%3CBR%20%2F%3ECan%20a%20solution%20be%20implemted%20using%20SharePoint%20search%20APIs%20or%20the%20Microsoft%20Graph%20%3F%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-214733%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-291063%22%20slang%3D%22en-US%22%3ERe%3A%20Office%20365%20-%20Retrieve%20all%20sites%20a%20user%20has%20access%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-291063%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20there%20information%20somewhere%20on%20how%20to%20set%20this%20up%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217919%22%20slang%3D%22en-US%22%3ERe%3A%20Office%20365%20-%20Retrieve%20all%20sites%20a%20user%20has%20access%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217919%22%20slang%3D%22en-US%22%3EAzure%20AD%20app%20regustration%20has%20permissions%20that%20allow%20an%20app%20to%20Search%20as%20another%20user%20for%20O365%20SharePoint%20Online.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-216259%22%20slang%3D%22en-US%22%3ERe%3A%20Office%20365%20-%20Retrieve%20all%20sites%20a%20user%20has%20access%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-216259%22%20slang%3D%22en-US%22%3EThe%20requirement%20is%20that%20a%20manger%20can%20see%20a%20report%20of%20the%20sites%20that%20his%20subordinate%20has%20access%20to.%3CBR%20%2F%3E%3CBR%20%2F%3ECan%20you%20please%20shed%20some%20light%20on%20how%20to%20achieve%20this%3F%20How%20do%20we%20simulate%20the%20user%20executing%20the%20API%20query%3F%3CBR%20%2F%3E%E2%80%9Cuse%20a%20user%20with%20the%20required%20permissions%20to%20get%20for%20each%20user%20the%20sites%20he%20can%20access.%E2%80%9D%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-214817%22%20slang%3D%22en-US%22%3ERe%3A%20Office%20365%20-%20Retrieve%20all%20sites%20a%20user%20has%20access%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-214817%22%20slang%3D%22en-US%22%3EYou%20don't%20need%20to%20simulate%20user%20authentication%2C%20just%20use%20a%20user%20with%20the%20required%20permissions%20to%20get%20for%20each%20user%20the%20sites%20he%20can%20access.%20I%20would%20recomend%20to%20use%20Search%20API%20for%20this%20requirement%3C%2FLINGO-BODY%3E
Contributor
What is the best way to retrieve all sites a user has access to in Office 365 using a script that runs outside Office 365 and how do we simulate user authentication ?

Can a solution be implemted using SharePoint search APIs or the Microsoft Graph ?
4 Replies
You don't need to simulate user authentication, just use a user with the required permissions to get for each user the sites he can access. I would recomend to use Search API for this requirement
The requirement is that a manger can see a report of the sites that his subordinate has access to.

Can you please shed some light on how to achieve this? How do we simulate the user executing the API query?
“use a user with the required permissions to get for each user the sites he can access.”
Azure AD app regustration has permissions that allow an app to Search as another user for O365 SharePoint Online.

Is there information somewhere on how to set this up?