none
listing subsites in SPO

    Question

  • Would it be possible to find all subsites of a sitecollection using global admin account in SharePoint Online?  

    I have a scenario that ,display logged in user's subsites from  Site collection A  on a page in Sitecollection B.  ( Logged user may or may not have access to Site collection A but user might have access to few subsites.  Users would want to know all the sites he/she may have access)  So would it be possible to loop through all sitecollection using global admin account something likerun with elevated privileges in server side ( on premise).  Can you please through somelight on this. 

    How to retrieve all subsites user may have access of a site collection if user doesn't has access to site collection?

    Friday, February 24, 2017 11:26 AM

Answers

All replies

  • Yes, you can. Refer to the following post, hope it helps

    https://gallery.technet.microsoft.com/SharePoint-2013-Get-all-65ae2e68?redir=0


    Cheers,
    My Blog

    Monday, February 27, 2017 5:19 AM
  • Thank you for response. Need one more clarification. Would be great if you reply. 

    Would it be possible to verify whether logged user has access to a particular site if we pass site URL in SharePoint Online? verify using either global admin account or using logged user ID through client side object model OR JSOM?  

    For example:  I have two site collections Sitecollection A and Site collection B ,  every one ( all users) has access to Site Collection A and only few users has access to subsites in Sitecollection B. The scenario we need is,  to display all subsites from both site collection A & B of logged user has access to? 

    xx.sharepoint.com/A , A has a1, a2 and a3 subsites.

    xx.sharepoint.com/B , B has b1, b2 and b3 subsites. 

    I am thinking to if we loop through all site collection using global admin account to find subsites , groups and user who have access ?  if its not possible to loop through using global admin account , i would  maintain list of all subsites from A & B in separate list in Site collection A 

    xx.sharepoint.com/A/a1,xx.sharepoint.com/A/a2, xx.sharepoint.com/A/a3 , xx.sharepoint.com/B/b1, xx.sharepoint.com/B/b2, xx.sharepoint.com/B/b3 

    So my quesiton is  if we maintain a list of subsites within a list we won’t able to check the permission of that subset in another site collection as the SPContext in CSOM(JS) is bound to the site collection in which is called for.  We won’t be able to lookup information from an another site collection using SPContext in SP Online as its will always bound to Site Collection where script is executing.

    Using the url pattern to create & access SPContext for anther site collection will fail unless done using AppContext/App Token (we cannot verify user permissions here). AppContext with User Context token is also limited to the execution environment i.e site collection/site where the app is deployed.

    So is it possible to find the sites from all site collection of logged user has access in SharePoint Online ? Please reply. I would need perform this programmatic ally ( not thru powershell )

    Tuesday, February 28, 2017 3:57 PM
  • You can use CSOM. Use SPOSitePropertiesEnumerable class to get all Site collections and use DoesUserHavePermissions() method to check if the user is having access to the site. Refer to the following posts for more information

    http://sharepoint.stackexchange.com/questions/133073/get-all-site-collections-with-csom

    http://sharepoint.stackexchange.com/questions/164947/does-csom-have-a-way-to-check-if-the-current-user-has-access-to-a-web


    Cheers,
    My Blog

    • Marked as answer by cnivass Tuesday, March 7, 2017 6:33 AM
    Wednesday, March 1, 2017 5:11 AM
  • Hi cnivass,

    Any update about Prasath's suggestion?

    Best regards,

    Patrick


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by cnivass Tuesday, March 7, 2017 6:33 AM
    Friday, March 3, 2017 5:53 AM
    Moderator
  • Thank you its worked for me.
    Tuesday, March 7, 2017 6:33 AM