3
votes

Hi I am using client object model in .net to access sharepoint data. I have site in which i have some subsites. out of these subsites some sites are not accisible to me. I want to get the list of this subsites (at least title for that subsite), so i can inform the user that this are the subsites on which he dont have access.

Is there any way to achive this using the client object model in the .Net.

currently i am using getsubwebsforcurrentuser method as follows: which gives me the list of subsite on which i have access. but i am more interested in subsite title on which i dont have access.

ClientContext clientContext = new ClientContext(path);
                Web oWebsite = clientContext.Web;
                WebCollection collWeb = oWebsite.GetSubwebsForCurrentUser(null);
                clientContext.Load(collWeb);

Earlier i used the following code. which is throwing serverunauthorizedaccessexception eception, obviously because i dont have access on one of the subsite

            ClientContext clientContext = new ClientContext(path);
            Web oWebsite = clientContext.Web;
            clientContext.Load(oWebsite, website => website.Webs, website => website.Title);

So kindly help me to get the list of subsites on which i dont have access, if there is any way to achive this?

1

1 Answers

0
votes

Not via CSOM due to security trimming.

But you could accomplish it via SharePoint Web Services, in particular using Webs.GetWebCollection method:

using(var proxy = new Webs())
{
     proxy.Url = webUri + "/_vti_bin/Webs.asmx"; 
     var result = proxy.GetWebCollection();
     var nodes = result.SelectNodes("*");
     foreach (XmlNode node in nodes)
     {
            var webTitle = node.Attributes["Title"].Value;

     }
}