From 6366a07c5c1c4f8a92c3db608b4b80fd58a8ceaf Mon Sep 17 00:00:00 2001 From: Janne Holm Date: Thu, 12 Dec 2024 13:23:44 +0200 Subject: [PATCH] Added tenantAdminUrl parameter for GetHubSiteChildUrls --- src/lib/PnP.Framework/Extensions/TenantExtensions.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/PnP.Framework/Extensions/TenantExtensions.cs b/src/lib/PnP.Framework/Extensions/TenantExtensions.cs index d64e1e530..8489ffaed 100644 --- a/src/lib/PnP.Framework/Extensions/TenantExtensions.cs +++ b/src/lib/PnP.Framework/Extensions/TenantExtensions.cs @@ -66,13 +66,14 @@ public static ProvisioningHierarchy GetTenantTemplate(this Tenant tenant, Extrac /// /// A tenant object pointing to the context of a Tenant Administration site /// The fully qualified url of the hubsite + /// 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. /// - public static List GetHubSiteChildUrls(this Tenant tenant, string hubSiteUrl) + public static List GetHubSiteChildUrls(this Tenant tenant, string hubSiteUrl, string tenantAdminUrl = null) { var properties = tenant.GetHubSitePropertiesByUrl(hubSiteUrl); tenant.Context.Load(properties); tenant.Context.ExecuteQueryRetry(); - return GetHubSiteChildUrls(tenant, properties.ID); + return GetHubSiteChildUrls(tenant, properties.ID, tenantAdminUrl); } /// @@ -80,11 +81,12 @@ public static List GetHubSiteChildUrls(this Tenant tenant, string hubSit /// /// A tenant object pointing to the context of a Tenant Administration site /// The id of the hubsite + /// 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. /// - public static List GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteId) + public static List GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteId, string tenantAdminUrl = null) { List urls = new List(); - 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())) { var siteList = tenantContext.Web.Lists.GetByTitle(SPO_ADMIN_SITECOL_LIST_TITLE); siteList.EnsureProperty(l => l.Id);