【问题标题】:Creating site collection programmatically with custom site template in Office 365 APP在 Office 365 APP 中使用自定义网站模板以编程方式创建网站集
【发布时间】:2014-04-21 21:38:29
【问题描述】:

我正在尝试通过自动托管应用在 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 的网站集的解决方案库中。在以编程方式创建新网站集的过程中,我是否可以上传此网站模板并激活它?

【问题讨论】:

    标签: sharepoint-2013 office365 office365-apps


    【解决方案1】:

    没有太多关于如何在 C# 中使用 Microsoft.Online.SharePoint.Client.Tenant.dll 的文档,但是您可以从 SharePoint online Powershell commands 中了解它,因为某些 Powershell 命令是基于此 DLL 的。

    如要创建网站集,参数“Template”为你要使用的模板名称,如要查找自定义网站模板的名称,可以使用powershell命令“Get-SPOWebTemplate”,将列出所有带有名称的模板。

    注意,Template 和 LocaleId 参数必须是从 Get-SPOWebTemplate cmdlet 返回的有效组合。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      • 1970-01-01
      • 2011-07-07
      • 2014-07-26
      • 2010-10-10
      • 2013-06-03
      相关资源
      最近更新 更多