locked
Get a list of all sites a user has access to RRS feed

  • Question

  • I have to get a list of all the sites a user has access to in sharepoint 2007. I am using the object model. Is there something in the API I can leverage?

     

    Thanks,

    Malhar

    Monday, September 12, 2011 5:35 AM

Answers

All replies

  • Hi,

    if you want get the collection of all webs from the site collection then you can use below code:

    using(SPSite site = new SPSite("http://sitename/"))
    {
        using (SPWeb web = site.OpenWeb())
        {
            SPWebCollection webCollection = web.GetSubwebsForCurrentUser();
        }
    }

    Or else you can also use codeplex tool to get all the site collection from the farm:

    http://spuac.codeplex.com/

    http://accesschecker.codeplex.com/

    Hope it could help


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Monday, September 12, 2011 6:10 AM
  • Sounds Good! But once I have all the subsites, how can I get all the users and going through each find which user can access which sites?

    Also instead of using the object can I directly hit the database somehow, since I actually need these values on a PHP application running on our network.

     

    Thanks,

    Malhar

    Monday, September 12, 2011 6:30 AM
  • >on a PHP application running

    Then you should use SP web service. Object model will not work here. Here is the similar thread for your reference

    http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/7544b283-105b-4567-9399-5ac8bdf9a175/

    >how can I get all the users and going through each find which user can access which sites

    You may use usergroup.asmx service to get all user and sites.asmx for get all the site collection. See all services available in sharepoint

    http://msdn.microsoft.com/en-us/library/bb862916%28v=office.12%29.aspx

    Hope it could help


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    • Marked as answer by Pengyu Zhao Thursday, September 22, 2011 1:46 AM
    Monday, September 12, 2011 6:44 AM