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 support for passing in a tenant admin url to support vanity domains #1012

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
5 changes: 3 additions & 2 deletions src/lib/PnP.Framework/Extensions/TenantExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ public static List<string> GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteI
/// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site</param>
/// <param name="siteId">The id of the site collection</param>
/// <param name="detailed">Boolean indicating if detailed information should be returned of the site (true - default) or only the basics (false)</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>SiteProperties of the site collection or NULL of no site collection found with the provided Id</returns>
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);
Expand Down
Loading