Class TenantExtensions
Class for tenant extension methods
Inheritance
Namespace: Microsoft.SharePoint.Client
Assembly: PnP.Framework.dll
Syntax
public static class TenantExtensions : object
Methods
AddAdministrators(Tenant, IEnumerable<UserEntity>, Uri, Boolean)
Add a site collection administrator to a site collection
Declaration
public static void AddAdministrators(this Tenant tenant, IEnumerable<UserEntity> adminLogins, Uri siteUrl, bool addToOwnersGroup = false)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
IEnumerable<User Array of admins loginnames to add |
Uri
siteUrl
Url of the site to operate on |
System. Optionally the added admins can also be added to the Site owners group |
ApplyProvisionHierarchy(Tenant, ProvisioningHierarchy, String, ProvisioningTemplateApplyingInformation)
Declaration
public static void ApplyProvisionHierarchy(this Tenant tenant, ProvisioningHierarchy hierarchy, string sequenceId, ProvisioningTemplateApplyingInformation applyingInformation = null)
Parameters
Tenant
tenant
|
Provisioning
|
System.
|
Provisioning
|
ApplyTenantTemplate(Tenant, ProvisioningHierarchy, String, ApplyConfiguration)
Applies a template to a tenant
Declaration
public static void ApplyTenantTemplate(this Tenant tenant, ProvisioningHierarchy tenantTemplate, string sequenceId, ApplyConfiguration configuration = null)
Parameters
Tenant
tenant
|
Provisioning
|
System.
|
Apply
|
CheckIfSiteExists(Tenant, String, String)
Returns if a site collection is in a particular status. If the URL contains a sub site then returns true is the sub site exists, false if not. Status is irrelevant for sub sites
Declaration
public static bool CheckIfSiteExists(this Tenant tenant, string siteFullUrl, string status)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. Url to the site collection |
System. Status to check (Active, Creating, Recycled) |
Returns
System. True if in status, false if not in status |
CreateSiteCollection(Tenant, SiteEntity, Boolean, Boolean, Func<TenantOperationMessage, Boolean>)
Adds a SiteEntity by launching site collection creation and waits for the creation to finish
Declaration
public static Guid CreateSiteCollection(this Tenant tenant, SiteEntity properties, bool removeFromRecycleBin = false, bool wait = true, Func<TenantOperationMessage, bool> timeoutFunction = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
Site Describes the site collection to be created |
System. It true and site is present in recycle bin, it will be removed first from the recycle bin |
System. If true, processing will halt until the site collection has been created |
Func<Tenant An optional function that will be called while waiting for the site to be created. If set will override the wait variable. Return true to cancel the wait loop. |
Returns
Guid
Guid of the created site collection and Guid.Empty is the wait parameter is specified as false. Returns Guid.Empty if the wait is cancelled. |
CreateSiteCollection(Tenant, String, String, String, String, Int32, Int32, Int32, Int32, Int32, UInt32, Boolean, Boolean, Func<TenantOperationMessage, Boolean>)
Launches a site collection creation and waits for the creation to finish
Declaration
public static Guid CreateSiteCollection(this Tenant tenant, string siteFullUrl, string title, string siteOwnerLogin, string template, int storageMaximumLevel, int storageWarningLevel, int timeZoneId, int userCodeMaximumLevel, int userCodeWarningLevel, uint lcid, bool removeFromRecycleBin = false, bool wait = true, Func<TenantOperationMessage, bool> timeoutFunction = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. The SPO URL |
System. The site title |
System. Owner account |
System. Site template being used |
System. Site quota in MB |
System. Site quota warning level in MB |
System. TimeZoneID for the site. "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris" = 3 |
System. The user code quota in points |
System. The user code quota warning level in points |
System. The site locale. See http://technet.microsoft.com/en-us/library/ff463597.aspx for a complete list of Lcid's |
System. If true, any existing site with the same URL will be removed from the recycle bin |
System. Wait for the site to be created before continuing processing |
Func<Tenant An optional function that will be called while waiting for the site to be created. If set will override the wait variable. Return true to cancel the wait loop. |
Returns
Guid
Guid of the created site collection and Guid.Empty is the wait parameter is specified as false. Returns Guid.Empty if the wait is cancelled. |
DeleteSiteCollection(Tenant, String, Boolean, Func<TenantOperationMessage, Boolean>)
Deletes a site collection
Declaration
public static bool DeleteSiteCollection(this Tenant tenant, string siteFullUrl, bool useRecycleBin, Func<TenantOperationMessage, bool> timeoutFunction = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. Url of the site collection to delete |
System. Leave the deleted site collection in the site collection recycle bin |
Func<Tenant An optional function that will be called while waiting for the site to be created. Return true to cancel the wait loop. |
Returns
System. True if deleted |
DeleteSiteCollectionFromRecycleBin(Tenant, String, Boolean, Func<TenantOperationMessage, Boolean>)
Deletes a site collection from the site collection recycle bin
Declaration
public static bool DeleteSiteCollectionFromRecycleBin(this Tenant tenant, string siteFullUrl, bool wait = true, Func<TenantOperationMessage, bool> timeoutFunction = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. URL of the site collection to delete |
System. If true, processing will halt until the site collection has been deleted from the recycle bin |
Func<Tenant An optional function that will be called while waiting for the site to be created. If set will override the wait variable. Return true to cancel the wait loop. |
Returns
System.
|
DisableSiteClassifications(Tenant, String)
Disables Site Classifications settings for the target tenant
Declaration
public static void DisableSiteClassifications(this Tenant tenant, string accessToken)
Parameters
Tenant
tenant
The target tenant |
System. The OAuth accessToken for Microsoft Graph with Azure AD |
EnableCommSite(Tenant, String)
Enable communication site on the root site of a tenant
Declaration
public static void EnableCommSite(this Tenant tenant, string siteUrl = "")
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. Root site url of your tenant |
EnableCommunicationSite(Tenant, String)
Enable communication site on the root site of a tenant
Declaration
public static void EnableCommunicationSite(this Tenant tenant, string siteUrl = "")
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. Root site url of your tenant |
EnableSiteClassifications(Tenant, String, IEnumerable<String>, String, String)
Enables Site Classifications for the target tenant
Declaration
public static void EnableSiteClassifications(this Tenant tenant, string accessToken, IEnumerable<string> classificationsList, string defaultClassification = "", string usageGuidelinesUrl = "")
Parameters
Tenant
tenant
The target tenant |
System. The OAuth accessToken for Microsoft Graph with Azure AD |
IEnumerable<System. The list of classification values |
System. The default classification |
System. The URL of a guidance page |
EnableSiteClassifications(Tenant, String, SiteClassificationsSettings)
Enables Site Classifications for the target tenant
Declaration
public static void EnableSiteClassifications(this Tenant tenant, string accessToken, SiteClassificationsSettings siteClassificationsSettings)
Parameters
Tenant
tenant
The target tenant |
System. The OAuth accessToken for Microsoft Graph with Azure AD |
Site The site classifications settings to apply. |
EnsureAppCatalogAsync(Tenant, String, String, Int32, Boolean)
Creates a new App Catalog and registers the app catalog site as the tenant App Catalog.
Declaration
public static async Task EnsureAppCatalogAsync(this Tenant tenant, string url, string ownerLogin, int timeZoneId, bool force = false)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. The Full Site Url, e.g. https://yourtenant.sharepoint.com/sites/appcatalog |
System. The username of the owner of the appcatalog, e.g. user@domain.com |
System. TimeZoneId for the appcatalog site. "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris" = 3" |
System. If true, and an appcatalog is already registered and present, the new appcatalog will be created. If the same URL is provided and the site is present the current one will be deleted and a new one will be created. |
Returns
Task
|
GetAppCatalog(Tenant)
Gets the Uri for the tenant's app catalog site (if that one has already been created)
Declaration
public static Uri GetAppCatalog(this Tenant tenant)
Parameters
Tenant
tenant
Tenant to operate against |
Returns
Uri
The Uri holding the app catalog site URL |
GetHubSiteChildUrls(Tenant, Guid, String)
Returns the urls of sites connected to the hubsite specified
Declaration
public static List<string> GetHubSiteChildUrls(this Tenant tenant, Guid hubsiteId, string tenantAdminUrl = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
Guid
hubsiteId
The id of the hubsite |
System. 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. |
Returns
List<System.
|
GetHubSiteChildUrls(Tenant, String, String)
Returns the urls of sites connected to the hubsite specified
Declaration
public static List<string> GetHubSiteChildUrls(this Tenant tenant, string hubSiteUrl, string tenantAdminUrl = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. The fully qualified url of the hubsite |
System. 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. |
Returns
List<System.
|
GetSiteClassificationsSettings(Tenant, String)
Enables Site Classifications for the target tenant
Declaration
public static SiteClassificationsSettings GetSiteClassificationsSettings(this Tenant tenant, string accessToken)
Parameters
Tenant
tenant
The target tenant |
System. The OAuth accessToken for Microsoft Graph with Azure AD |
Returns
Site The list of Site Classifications values |
GetSiteCollections(Tenant, Int32, Int32, Boolean, Boolean)
Returns all site collections in the current Tenant based on a startIndex. IncludeDetail adds additional properties to the SPSite object.
Declaration
public static IList<SiteEntity> GetSiteCollections(this Tenant tenant, int startIndex = 0, int endIndex = 500000, bool includeDetail = true, bool includeOD4BSites = false)
Parameters
Tenant
tenant
Tenant object to operate against |
System. Not relevant anymore |
System. Not relevant anymore |
System. Option to return a limited set of data |
System. Also return the OD4B sites |
Returns
IList<Site An IList of SiteEntity objects |
GetSiteGuidByUrl(Tenant, String)
Gets the ID of site collection with specified URL
Declaration
public static Guid GetSiteGuidByUrl(this Tenant tenant, string siteFullUrl)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. A URL that specifies a site collection to get ID. |
Returns
Guid
The Guid of a site collection |
GetSiteGuidByUrl(Tenant, Uri)
Gets the ID of site collection with specified URL
Declaration
public static Guid GetSiteGuidByUrl(this Tenant tenant, Uri siteFullUrl)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
Uri
siteFullUrl
A URL that specifies a site collection to get ID. |
Returns
Guid
The Guid of a site collection or an Guid.Empty if the Site does not exist |
GetSitePropertiesById(Tenant, Guid, Boolean, String)
Returns details of a site collection by its site collection Id
Declaration
public static SiteProperties GetSitePropertiesById(this Tenant tenant, Guid siteId, bool detailed = true, string tenantAdminUrl = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
Guid
siteId
The id of the site collection |
System. Boolean indicating if detailed information should be returned of the site (true - default) or only the basics (false) |
System. 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. |
Returns
Site SiteProperties of the site collection or NULL of no site collection found with the provided Id |
GetTenantIdByUrl(String, AzureEnvironment)
Declaration
public static string GetTenantIdByUrl(string tenantUrl, AzureEnvironment azureEnvironment = default(AzureEnvironment))
Parameters
System.
|
Azure
|
Returns
System.
|
GetTenantRootSiteUrl(Tenant)
Declaration
public static string GetTenantRootSiteUrl(this Tenant tenant)
Parameters
Tenant
tenant
|
Returns
System.
|
GetTenantTemplate(Tenant, ExtractConfiguration)
Extracts a template from a tenant
Declaration
public static ProvisioningHierarchy GetTenantTemplate(this Tenant tenant, ExtractConfiguration configuration)
Parameters
Tenant
tenant
|
Extract
|
Returns
GetWebTemplates(Tenant, UInt32, Int32)
Returns available webtemplates/site definitions
Declaration
public static SPOTenantWebTemplateCollection GetWebTemplates(this Tenant tenant, uint lcid, int compatibilityLevel)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. Locale identifier (LCID) for the language |
System. 14 for SharePoint 2010, 15 for SharePoint 2013/SharePoint Online |
Returns
SPOTenant Returns collection of SPTenantWebTemplate |
GroupifySite(Tenant, String, TeamSiteCollectionGroupifyInformation)
Connect an Office 365 group to an existing SharePoint site collection
Declaration
public static void GroupifySite(this Tenant tenant, string siteUrl, TeamSiteCollectionGroupifyInformation siteCollectionGroupifyInformation)
Parameters
Tenant
tenant
The target tenant |
System. Url to the site collection that needs to get connected to an Office 365 group |
Team Information that configures the "groupify" process |
IsCurrentUserTenantAdmin(ClientContext)
Returns if the current user is a tenant administrator
Declaration
public static bool IsCurrentUserTenantAdmin(ClientContext clientContext)
Parameters
Client
|
Returns
System.
|
IsCurrentUserTenantAdmin(ClientContext, String)
Declaration
public static bool IsCurrentUserTenantAdmin(ClientContext clientContext, string tenantAdminSiteUrl)
Parameters
Client
|
System.
|
Returns
System.
|
IsSiteActive(Tenant, String)
Checks if a site collection is Active
Declaration
public static bool IsSiteActive(this Tenant tenant, string siteFullUrl)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. URL to the site collection |
Returns
System. True if active, false if not |
SetSiteLockState(Tenant, String, SiteLockState, Boolean, Func<TenantOperationMessage, Boolean>)
Sets a site to Unlock access or NoAccess. This operation may occur immediately, but the site lock may take a short while before it goes into effect.
Declaration
public static void SetSiteLockState(this Tenant tenant, string siteFullUrl, SiteLockState lockState, bool wait = false, Func<TenantOperationMessage, bool> timeoutFunction = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site (i.e. https://[tenant]-admin.sharepoint.com) |
System. The target site to change the lock state. |
Site The target state the site should be changed to. |
System. If true, processing will halt until the site collection lock state has been implemented |
Func<Tenant An optional function that will be called while waiting for the site to be created. If set will override the wait variable. Return true to cancel the wait loop. |
SetSiteProperties(Tenant, String, String, Nullable<Boolean>, Nullable<SharingCapabilities>, Nullable<Int64>, Nullable<Int64>, Nullable<Double>, Nullable<Double>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Online.SharePoint.TenantManagement.SharingPermissionType>, Nullable<Online.SharePoint.TenantManagement.SharingLinkType>, Boolean, Func<TenantOperationMessage, Boolean>)
Sets tenant site Properties
Declaration
public static void SetSiteProperties(this Tenant tenant, string siteFullUrl, string title = null, bool? allowSelfServiceUpgrade = null, SharingCapabilities? sharingCapability = null, long? storageMaximumLevel = null, long? storageWarningLevel = null, double? userCodeMaximumLevel = null, double? userCodeWarningLevel = null, bool? noScriptSite = null, bool? commentsOnSitePagesDisabled = null, bool? socialBarOnSitePagesDisabled = null, Online.SharePoint.TenantManagement.SharingPermissionType? defaultLinkPermission = null, Online.SharePoint.TenantManagement.SharingLinkType? defaultSharingLinkType = null, bool wait = true, Func<TenantOperationMessage, bool> timeoutFunction = null)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. full URL of site |
System. site title |
System. Boolean value to allow serlf service upgrade |
System. SharingCapabilities enumeration value (i.e. Disabled/ExternalUserSharingOnly/ExternalUserAndGuestSharing/ExistingExternalUserSharingOnly) |
System. A limit on all disk space used by the site collection |
System. A storage warning level for when administrators of the site collection receive advance notice before available storage is expended. |
System. A value that represents the maximum allowed resource usage for the site/ |
System. A value that determines the level of resource usage at which a warning e-mail message is sent |
System. Boolean value which allows to customize the site using scripts |
System. Boolean value which Enables/Disables comments on the Site Pages |
System. Boolean value which Enables/Disables likes and view count on the Site Pages |
System. Specifies the default link permission for the site collection |
System. Specifies the default link type for the site collection |
System. Id true this function only returns when the tenant properties are set, if false it will return immediately |
Func<Tenant An optional function that will be called while waiting for the tenant properties to be set. If set will override the wait variable. Return true to cancel the wait loop. |
SiteExists(Tenant, String)
Checks if a site collection exists, relies on tenant admin API. Sites that are recycled also return as existing sites
Declaration
public static bool SiteExists(this Tenant tenant, string siteFullUrl)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. URL to the site collection |
Returns
System. True if existing, false if not |
SiteExistsAnywhere(Tenant, String)
Checks if a site collection exists, relies on tenant admin API. Sites that are recycled also return as existing sites, but with a different flag
Declaration
public static SiteExistence SiteExistsAnywhere(this Tenant tenant, string siteFullUrl)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. URL to the site collection |
Returns
Site An enumerated type that can be: No, Yes, Recycled |
SubSiteExists(Tenant, String)
Checks if a sub site exists
Declaration
public static bool SubSiteExists(this Tenant tenant, string siteFullUrl)
Parameters
Tenant
tenant
A tenant object pointing to the context of a Tenant Administration site |
System. URL to the sub site |
Returns
System. True if existing, false if not |
UpdateSiteClassificationsSettings(Tenant, String, IEnumerable<String>, String, String)
Updates Site Classifications settings for the target tenant
Declaration
public static void UpdateSiteClassificationsSettings(this Tenant tenant, string accessToken, IEnumerable<string> classificationsList, string defaultClassification = "", string usageGuidelinesUrl = "")
Parameters
Tenant
tenant
The target tenant |
System. The OAuth accessToken for Microsoft Graph with Azure AD |
IEnumerable<System. The list of classification values |
System. The default classification |
System. The URL of a guidance page |
UpdateSiteClassificationsSettings(Tenant, String, SiteClassificationsSettings)
Updates Site Classifications settings for the target tenant
Declaration
public static void UpdateSiteClassificationsSettings(this Tenant tenant, string accessToken, SiteClassificationsSettings siteClassificationsSettings)
Parameters
Tenant
tenant
The target tenant |
System. The OAuth accessToken for Microsoft Graph with Azure AD |
Site The site classifications settings to update. |