コード例 #1
0
        private static Guid GetSiteDesignId(CommonNoGroupSiteOptions siteCollectionCreationInformation)
        {
            if (siteCollectionCreationInformation.SiteDesignId != Guid.Empty)
            {
                return(siteCollectionCreationInformation.SiteDesignId);
            }
            else if (siteCollectionCreationInformation is CommunicationSiteOptions communicationSiteOptions)
            {
                switch (communicationSiteOptions.SiteDesign)
                {
                case CommunicationSiteDesign.Topic:
                {
                    return(Guid.Empty);
                }

                case CommunicationSiteDesign.Showcase:
                {
                    return(Guid.Parse("6142d2a0-63a5-4ba0-aede-d9fefca2c767"));
                }

                case CommunicationSiteDesign.Blank:
                {
                    return(Guid.Parse("f6cc5403-0d63-442e-96c0-285923709ffc"));
                }
                }
            }

            return(Guid.Empty);
        }
コード例 #2
0
 private static Dictionary <string, object> BuildBaseCommonNoGroupSiteRequestPayload(CommonNoGroupSiteOptions siteCollectionCreationInformation)
 {
     return(new Dictionary <string, object>
     {
         { "Title", siteCollectionCreationInformation.Title },
         { "Lcid", (int)siteCollectionCreationInformation.Language },
         { "ShareByEmailEnabled", siteCollectionCreationInformation.ShareByEmailEnabled },
         { "Url", siteCollectionCreationInformation.Url },
         { "Classification", siteCollectionCreationInformation.Classification ?? "" },
         { "Description", siteCollectionCreationInformation.Description ?? "" },
         { "WebTemplate", siteCollectionCreationInformation.WebTemplate },
         { "WebTemplateExtensionId", Guid.Empty },
         { "Owner", siteCollectionCreationInformation.Owner }
     });
 }
コード例 #3
0
        private static async Task <PnPContext> CreateCommonNoGroupSiteAsync(PnPContext context, CommonNoGroupSiteOptions siteToCreate, SiteCreationOptions creationOptions)
        {
            if (string.IsNullOrEmpty(siteToCreate.Owner) && creationOptions.UsingApplicationPermissions.Value)
            {
                throw new ClientException(ErrorType.Unsupported, "You need to set an owner when using Application permissions to create a communicaiton site");
            }

            var payload = BuildBaseCommonNoGroupSiteRequestPayload(siteToCreate);

            var siteDesignId = GetSiteDesignId(siteToCreate);

            if (siteDesignId != Guid.Empty)
            {
                payload.Add("SiteDesignId", siteDesignId);

                // As per https://github.com/SharePoint/sp-dev-docs/issues/4810 the WebTemplateExtensionId property
                // is what currently drives the application of a custom site design during the creation of a modern site.
                payload["WebTemplateExtensionId"] = siteDesignId;
            }

            payload.Add("HubSiteId", siteToCreate.HubSiteId);

            // Sensitivity labels have replaced classification (see https://docs.microsoft.com/en-us/microsoft-365/compliance/sensitivity-labels-teams-groups-sites?view=o365-worldwide#classic-azure-ad-group-classification)
            // once enabled. Therefore we prefer setting a sensitivity label id over classification when specified.
            if (siteToCreate.SensitivityLabelId != Guid.Empty)
            {
                payload.Add("SensitivityLabel", siteToCreate.SensitivityLabelId);
            }
            else
            {
                payload["Classification"] = siteToCreate.Classification ?? "";
            }

            return(await CreateSiteUsingSpoRestImplementationAsync(context, SiteCreationModel.SPSiteManagerCreate, payload, creationOptions).ConfigureAwait(false));
        }