Question

I’m trying to learn SharePoint Client Object Model, specifically how to get a list of all SharePoint site URLs using a remote connection. This is possible using webservices…but I want to do it using the client object model.

I’ve figured how to get the title lists of a specific sharepoint site using the following code:

client object module):
  ClientContext  ctx = new ClientContext( server );
  ctx.AuthenticationMode = ClientAuthenticationMode.Default;
  ctx.Credentials = WindowsAuthenticationCredentials(username, password);

 Web w = ctx.Web;
var lists = ctx.LoadQuery(w.Lists);
 ctx.ExecuteQuery();

//Enumerate the results.
foreach (List theList in lists)
{

}

Output:

Announcements, Master Collection Pages… etc…

How can I do the same to get a site url list?

In web services you can call the following to achieve that, but as I said just trying to figure out how to do the same using client object module. If you can provide c# code that would greatly be appreciated.

WSPSitedata.SiteData sitedata = new SiteData();
sitedata.Url = @SharePointBaseURL + @"_vti_bin/sitedata.asmx";
sitedata.Credentials = our_credentials
_sSiteMetadata metaData = new _sSiteMetadata();
_sWebWithTime[] webWithTime 
 sitedata.GetSite(out metaData, out webWithTime, out users, out groups, out vgroups);
Was it helpful?

Solution

The SharePoint Client Object Model CSOM is designed to remotly interact with your SiteCollection. Sure, it is possible to connect to various SiteCollections, but it's not possible to look over all SiteCollections sitting within a SPWebApplications.

In 2010 you could still use the ASMX WebServices which are available in earlier versions of SharePoint.

To get a better understanding of the CSOM you should have a look at the MSDN site http://msdn.microsoft.com/en-us/library/ee537247.aspx

Did you really mean a list containing all SiteCollection URLs or was that a misunderstanding?

Thorsten

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top