本文整理汇总了C#中Tenant.SetSiteProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Tenant.SetSiteProperties方法的具体用法?C# Tenant.SetSiteProperties怎么用?C# Tenant.SetSiteProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tenant
的用法示例。
在下文中一共展示了Tenant.SetSiteProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnableExternalSharing
public void EnableExternalSharing(Tenant tenant, Site site)
{
ClientContext context = (ClientContext)site.Context;
tenant.SetSiteProperties(site.Url, sharingCapability: SharingCapabilities.ExternalUserSharingOnly);
SiteProperties siteProps = tenant.GetSitePropertiesByUrl(site.Url, false);
context.Load(tenant);
context.Load(siteProps);
context.ExecuteQuery();
}
示例2: CreateTestSiteCollection
internal static string CreateTestSiteCollection(Tenant tenant, string sitecollectionName, bool isNoScriptSite = false)
{
try
{
string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
string siteOwnerLogin = ConfigurationManager.AppSettings["SPOUserName"];
if (TestCommon.AppOnlyTesting())
{
using (var clientContext = TestCommon.CreateClientContext())
{
List<UserEntity> admins = clientContext.Web.GetAdministrators();
siteOwnerLogin = admins[0].LoginName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)[2];
}
}
SiteEntity siteToCreate = new SiteEntity()
{
Url = siteToCreateUrl,
Template = "STS#0",
Title = "Test",
Description = "Test site collection",
SiteOwnerLogin = siteOwnerLogin,
Lcid = 1033,
StorageMaximumLevel = 100,
UserCodeMaximumLevel = 0
};
tenant.CreateSiteCollection(siteToCreate, false, true);
if (isNoScriptSite)
{
tenant.SetSiteProperties(siteToCreateUrl, noScriptSite: true);
}
return siteToCreateUrl;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToDetailedString());
throw;
}
}
示例3: SetExternalSharing
/// <summary>
/// Used to set External Sharing
/// </summary>
/// <param name="siteInfo"></param>
public override void SetExternalSharing(SiteInformation siteInfo)
{
UsingContext(ctx =>
{
try
{
Stopwatch _timespan = Stopwatch.StartNew();
Tenant _tenant = new Tenant(ctx);
_tenant.SetSiteProperties(siteInfo.Url, null, null, SharingCapabilities.ExternalUserSharingOnly);
SiteProperties _siteProps = _tenant.GetSitePropertiesByUrl(siteInfo.Url, false);
ctx.Load(_tenant);
ctx.Load(_siteProps);
ctx.ExecuteQuery();
bool _shouldBeUpdated = false;
var _tenantSharingCapability = _tenant.SharingCapability;
var _siteSharingCapability = _siteProps.SharingCapability;
var _targetSharingCapability = SharingCapabilities.Disabled;
if(siteInfo.EnableExternalSharing && _tenantSharingCapability != SharingCapabilities.Disabled)
{
_targetSharingCapability = SharingCapabilities.ExternalUserSharingOnly;
_shouldBeUpdated = true;
}
if (_siteSharingCapability != _targetSharingCapability && _shouldBeUpdated)
{
_siteProps.SharingCapability = _targetSharingCapability;
_siteProps.Update();
ctx.ExecuteQuery();
Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Successful, siteInfo.Url);
}
_timespan.Stop();
Log.TraceApi("SharePoint", "Office365SiteProvisioningService.SetExternalSharing", _timespan.Elapsed, "SiteUrl={0}", siteInfo.Url);
}
catch(ServerException _ex)
{
Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Exception, siteInfo.Url, _ex);
}
catch(Exception _ex)
{
Log.Info("Provisioning.Common.Office365SiteProvisioningService.SetExternalSharing", PCResources.ExternalSharing_Exception, siteInfo.Url, _ex);
}
});
}