I am trying to learn the object model of a SharePoint client, in particular, how to get a list of all the URLs of SharePoint sites using a remote connection. This is possible using webservices ... but I want to do this using the client object model.
I figured out how to get the header lists of a particular 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();
Output:
Announcements, Pages of the main collection ... etc.
How can I do the same to get a list of website urls?
In web services, you can call the following to achieve this, but, as I said, itβs just trying to figure out how to do the same with the client object module. If you can provide a C # code that would be much 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);
source share