string userName = WebConfigurationManager.AppSettings.Get("UserName");
string password = WebConfigurationManager.AppSettings.Get("Password");
string domain = WebConfigurationManager.AppSettings.Get("Domain");
using (var ctx = new ClientContext("http://siteUrl/"))
{
ctx.Credentials = new System.Net.NetworkCredential(userName, password, domain);
ctx.RequestTimeout = Timeout.Infinite;
var tenant = new Tenant(ctx);
var properties = new SiteCreationProperties()
{
Url = "http://siteUrl/sites/site1",
Owner = string.Format("{0}\\{1}",domain,userName),
Title = "Test Site",
Template = "STS#0"
};
SpoOperation op = tenant.CreateSite(properties);
ctx.Load(op, i => i.IsComplete);
ctx.ExecuteQuery();
}
string password = WebConfigurationManager.AppSettings.Get("Password");
string domain = WebConfigurationManager.AppSettings.Get("Domain");
using (var ctx = new ClientContext("http://siteUrl/"))
{
ctx.Credentials = new System.Net.NetworkCredential(userName, password, domain);
ctx.RequestTimeout = Timeout.Infinite;
var tenant = new Tenant(ctx);
var properties = new SiteCreationProperties()
{
Url = "http://siteUrl/sites/site1",
Owner = string.Format("{0}\\{1}",domain,userName),
Title = "Test Site",
Template = "STS#0"
};
SpoOperation op = tenant.CreateSite(properties);
ctx.Load(op, i => i.IsComplete);
ctx.ExecuteQuery();
}