Does the SharePoint Client Object Model have any method to access an object (List, Document, etc.) with just a single URL and valid credentials?
Essentially, I want to access an object (http://example.com/sites/Site1/Lib1/Sample.pdf) programmatically like this:
var credentials = new System.Net.NetworkCredential("user", "pass", "domain");
using (var sp = new ClientContext("http://example.com/sites/Site1/") { Credentials = credentials })
{
var file = sp.Web.GetFileByServerRelativeUrl("/Lib1/Sample.pdf");
sp.Load(file);
sp.ExecuteQuery();
}
I want to do this, except without knowing ahead of time which part of the URL corresponds to the site and which part points me to the object. So, I'm wondering if I have to make my own logic for this or if the Client Object Model has something for me to accomplish this.