Sunday, February 1, 2009

Programatically creating site collections

Scenario:
You want to programtically create many site collections.

Solution:
In-spite of going through UI to create all the site, a small utility can help.

Code:

// for the top-level site
string url = "/";

// this is the MS language Locale ID.
uint LCID = 1033;

// this is the site template for the
// Publishing Site - Collaboration Portal merged site definition
string template = "SPSPORTAL";

// create a site collection with an out of the box site definition
SPSite TopSiteCollection = webApp.Sites.Add(url,
"Top Site collection", "Description of this site",
LCID, template, "domain\\administrator",
"owner name", "email address");

// close the site collection
TopSiteCollection.Close();

0 comments: