Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tenantAdminUrl parameter for GetHubSiteChildUrls #1095

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/lib/PnP.Framework/Extensions/TenantExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,27 @@ public static ProvisioningHierarchy GetTenantTemplate(this Tenant tenant, Extrac
/// </summary>
/// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site</param>
/// <param name="hubSiteUrl">The fully qualified url of the hubsite</param>
/// <param name="tenantAdminUrl">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.</param>
/// <returns></returns>
public static List<string> GetHubSiteChildUrls(this Tenant tenant, string hubSiteUrl)
public static List<string> 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);
}

/// <summary>
/// Returns the urls of sites connected to the hubsite specified
/// </summary>
/// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site</param>
/// <param name="hubsiteId">The id of the hubsite</param>
/// <param name="tenantAdminUrl">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.</param>
/// <returns></returns>
public static List<string> GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteId)
public static List<string> GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteId, string tenantAdminUrl = null)
{
List<string> urls = new List<string>();
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);
Expand Down