I have been using this code to retrieve the URL of the top level site;
string result = String.Empty;
using (var service = GetSitesWebService())
{
result = service.GetSite(mySubSiteURL);
}
if (!String.IsNullOrWhiteSpace(result))
{
var doc = XDocument.Parse(result);
rootUrl = (string)doc.Element("Site").Attribute("Url");
}
This works fine if the user has certain permissions (not sure what they are), but if the user only has "Contributor" access then the above call to GetSite fails with a 401 - Unauthorized.
Is there any alternative approach to getting the top-level site URL, given some arbitrary site URL? I would strongly prefer to be able to do this via the Web Services, but the Client Object Model might have to do if web services don't support this for low-privilege users.