我正在尝试通过自动托管的应用在Office 365中创建网站集。我使用的是Microsoft.Online.SharePoint.Client.Tenant.dll,我的代码如下所示。
using System;
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using System.Security;
namespace SharePoint123
{
class Program
{
static void Main(string[] args)
{
//please change the value of user name, password, and admin portal URL
string username = "xxxx@xxxx.onmicrosoft.com";
String pwd = "xxxx";
ClientContext context = new ClientContext("https://xxxx-admin.sharepoint.com");
SecureString password = new SecureString();
foreach (char c in pwd.ToCharArray())
{
password.AppendChar(c);
}
context.Credentials = new SharePointOnlineCredentials(username, password);
Tenant t = new Tenant(context);
context.ExecuteQuery();//login into SharePoint online
//code to create a new site collection
var newsite = new SiteCreationProperties()
{
Url = "https://xxxxx.sharepoint.com/sites/createdbyProgram1",
Owner = "xxxxx@xxxxx.onmicrosoft.com",
Template = "STS#0", //using the team site template, check the MSDN if you want to use other template
StorageMaximumLevel = 100,
UserCodeMaximumLevel = 100,
UserCodeWarningLevel = 100,
StorageWarningLevel = 300,
Title = "CreatedbyPrgram",
CompatibilityLevel = 15, //15 means Shapoint online 2013, 14 means Sharepoint online 2010
};
t.CreateSite(newsite);
context.ExecuteQuery();
//end
}
}
}
但是,我想使用我创建的自定义网站模板,而不是" STS#0"团队网站模板。自定义网站模板存在于部署了我的APP的网站集的解决方案库中。在以编程方式创建新网站集期间,我是否可以上传此网站模板并将其激活?
答案 0 :(得分:1)
关于如何将Microsoft.Online.SharePoint.Client.Tenant.dll与C#一起使用的文档不多,但您可以从SharePoint online Powershell commands了解它,因为某些Powershell命令基于此DLL。
至于创建网站集,参数“Template”是您要使用的模板的名称,为了找到自定义网站模板的名称,您可以使用powershell命令“Get-SPOWebTemplate” ,它将列出所有带有名称的模板。
注意,Template和LocaleId参数必须是从Get-SPOWebTemplate cmdlet返回的有效组合。