/// <summary> /// Gets a site collection context for the passed web. This site collection client context uses the same credentials /// as the passed client context /// </summary> /// <param name="clientContext">Client context to take the credentials from</param> /// <returns>A site collection client context object for the site collection</returns> public static ClientContext GetSiteCollectionContext(this ClientRuntimeContext clientContext) { Site site = (clientContext as ClientContext).Site; if (!site.IsObjectPropertyInstantiated("Url")) { clientContext.Load(site); clientContext.ExecuteQueryRetry(); } return(clientContext.Clone(site.Url)); }
private static bool IsTenantAdminSite(ClientRuntimeContext clientContext) { try { using (var clonedContext = clientContext.Clone(clientContext.Url)) { var tenant = new Tenant(clonedContext); clonedContext.ExecuteQueryRetry(); return(true); } } catch (ClientRequestException x1) { return(false); } catch (ServerException x2) { return(false); } catch (WebException x3) { return(false); } }