From e78de5903cdca2f1382753f776f1bb8080929632 Mon Sep 17 00:00:00 2001 From: KoenZomers Date: Wed, 17 Apr 2024 00:20:52 +0200 Subject: [PATCH] Adding support for passing in a tenant admin url to support vanity domains --- src/lib/PnP.Framework/Extensions/TenantExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/PnP.Framework/Extensions/TenantExtensions.cs b/src/lib/PnP.Framework/Extensions/TenantExtensions.cs index 9da97583e..d64e1e530 100644 --- a/src/lib/PnP.Framework/Extensions/TenantExtensions.cs +++ b/src/lib/PnP.Framework/Extensions/TenantExtensions.cs @@ -135,11 +135,12 @@ public static List GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteI /// A tenant object pointing to the context of a Tenant Administration site /// The id of the site collection /// Boolean indicating if detailed information should be returned of the site (true - default) or only the basics (false) + /// The URL to use to connect to the tenant admin site. Typically only provided in the case of a vanity domain tenant. If not provided, tenant-admin will be assumed. /// SiteProperties of the site collection or NULL of no site collection found with the provided Id - public static SiteProperties GetSitePropertiesById(this Tenant tenant, Guid siteId, bool detailed = true) + public static SiteProperties GetSitePropertiesById(this Tenant tenant, Guid siteId, bool detailed = true, string tenantAdminUrl = null) { // Create a context to the SharePoint Online Admin site - using (var tenantContext = tenant.Context.Clone((tenant.Context as ClientContext).Web.GetTenantAdministrationUrl())) + using (var tenantContext = tenant.Context.Clone(tenantAdminUrl ?? (tenant.Context as ClientContext).Web.GetTenantAdministrationUrl())) { // Utilize the hidden list in the SharePoint Online Admin site to search for a site collection with matching Id using a CAML Query var siteList = tenantContext.Web.Lists.GetByTitle(SPO_ADMIN_SITECOL_LIST_TITLE);