Get the name of subsites on which a user does not have permission in sharepoint using the client object model

Hey. I am using the client object model in .net to access sharepoint data. I have a site where I have some sub-sites. of these sub-sites, some sites are not accessible to me. I want to get a list of these sub-sites (at least a header for this subsite), so I can tell the user that these are sub-sites that they don't have access to.

Is there a way to achieve this using the client object model in .Net.

I am currently using the getsubwebsforcurrentuser method like this, which gives me a list of the subsites that I have access to. but I'm more interested in the name of a sub-site that I don't have access to.

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

      

I have used the following code before. which throws a serverunauthorizedaccessexception , obviously because I don't have access to one of the child sites

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

      

So kindly help me get the list of sub sites that I don't have access to , if there is any way to achieve this?

+3


source to share


1 answer


Not via CSOM due to security clipping.

But you can do it through SharePoint Web Services, specifically using the 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;

     }
}   

      

0


source







All Articles