本文整理汇总了C#中SPSite.SelfServiceCreateSite方法的典型用法代码示例。如果您正苦于以下问题:C# SPSite.SelfServiceCreateSite方法的具体用法?C# SPSite.SelfServiceCreateSite怎么用?C# SPSite.SelfServiceCreateSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPSite
的用法示例。
在下文中一共展示了SPSite.SelfServiceCreateSite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSiteCollection
public string CreateSiteCollection(SiteData site)
{
string siteUrl = string.Empty;
uint siteLcIdint = 1033;
Guid siteId = SPContext.Current.Site.ID;
// Elevation - would not actually be neeeded if we call this by using specific account with the right permissions, but is also one option.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite elevSite = new SPSite(siteId))
{
if (!string.IsNullOrEmpty(site.LcId))
{
siteLcIdint = Convert.ToUInt16(site.LcId);
}
siteUrl = SPUrlUtility.CombineUrl(elevSite.Url, site.Url);
if (!SPSite.Exists(new Uri(siteUrl)))
{
using (SPSite newSite = elevSite.SelfServiceCreateSite(siteUrl, site.Title, site.Description,
siteLcIdint, site.WebTemplate,
site.OwnerLogin, string.Empty, string.Empty,
site.SecondaryContactLogin, string.Empty, string.Empty))
{
//create the default groups
newSite.RootWeb.CreateDefaultAssociatedGroups(newSite.Owner.LoginName, newSite.SecondaryContact.LoginName, site.Title);
}
}
else
{
//TODO - site already existed... abort abort!
}
}
});
return siteUrl;
}
示例2: SetUp
protected override void SetUp() {
base.SetUp();
DirectoryEntry root = new DirectoryEntry(_rootDirectory);
DirectoryEntry newUserEntry = root.Children.Add(_newUserName, "user");
newUserEntry.Invoke("SetPassword", _password);
newUserEntry.CommitChanges();
DirectoryEntry userEntry = root.Children.Add(_userName, "user");
userEntry.Invoke("SetPassword", _password);
userEntry.CommitChanges();
Uri uri = new Uri(_newSPSiteServerUrl);
SPSite site = new SPSite(uri.ToString());
SPSite newSite = site.SelfServiceCreateSite(
_newSPSiteUrl,
_newSPSiteTitle,
_newSPSiteDesc,
site.RootWeb.Language,
"STS",
_newSPSiteOwnerLogin,
_newSPSiteOwnerName,
_newSPSiteOwnerEmail,
_newSPSiteContactLogin,
_newSPSiteContactName,
_newSPSiteContactEmail);
}
示例3: SetUp
protected override void SetUp() {
base.SetUp();
DirectoryEntry root = new DirectoryEntry(_rootDirectory);
DirectoryEntry newUserEntry = root.Children.Add(_newUserName, "user");
newUserEntry.Invoke("SetPassword", _password);
newUserEntry.CommitChanges();
DirectoryEntry userEntry = root.Children.Add(_userName, "user");
userEntry.Invoke("SetPassword", _password);
userEntry.CommitChanges();
Uri uri = new Uri(_newSPSiteServerUrl);
SPSite site = new SPSite(uri.ToString());
SPSite newSite = site.SelfServiceCreateSite(
_newSPSiteUrl,
_newSPSiteTitle,
_newSPSiteDesc,
site.RootWeb.Language,
"STS",
_newSPSiteOwnerLogin,
_newSPSiteOwnerName,
_newSPSiteOwnerEmail,
_newSPSiteContactLogin,
_newSPSiteContactName,
_newSPSiteContactEmail);
// Add the test user to the site.
// SPSite site = new SPSite(_newSPSiteUrl);
SPRole role = newSite.RootWeb.Roles["Contributor"];
if (role == null) {
throw new Exception(string.Format(
"The role '{0}' does not exist", "Contributor"));
}
role.AddUser(_newUserLogin, "", "", "");
}
示例4: SetUp
protected override void SetUp() {
base.SetUp();
DirectoryEntry root = new DirectoryEntry(_rootDirectory);
DirectoryEntry userEntry = root.Children.Add(_userName, "user");
userEntry.Invoke("SetPassword", _password);
userEntry.CommitChanges();
Uri uri = new Uri(_newSPSiteServerUrl);
SPSite site = new SPSite(uri.ToString());
SPSite newSite = site.SelfServiceCreateSite(
_newSPSiteUrl,
_newSPSiteTitle,
_newSPSiteDesc,
site.RootWeb.Language,
"STS",
_newSPSiteOwnerLogin,
_newSPSiteOwnerName,
_newSPSiteOwnerEmail,
_newSPSiteContactLogin,
_newSPSiteContactName,
_newSPSiteContactEmail);
// Add the test role to the site.
newSite.RootWeb.Roles.Add(_testRoleName,
"dummy description",
SPRights.FullMask);
}
示例5: ExecuteTask
/// <summary>
/// Task for creating a SPSite.
/// </summary>
protected override void ExecuteTask() {
SPSite serverSite = new SPSite(Url);
string newSiteUrl = string.Format("{0}/{1}/{2}", Url, _managedPath, _abbreviation);
try {
SPSite newSite = serverSite.SelfServiceCreateSite(
newSiteUrl,
Title,
Description,
serverSite.RootWeb.Language,
Template,
OwnerLogin,
OwnerName,
OwnerEmail,
ContactLogin,
ContactName,
ContactEmail);
Log(Level.Info, LogPrefix + "Creating site {0}.", newSiteUrl);
} catch (SPException ex) {
throw new BuildException(
string.Format("Cannot create site {0}. The site does not exist.",
Url), Location, ex);
}
}