当前位置: 首页>>代码示例>>C#>>正文


C# SPSite.SelfServiceCreateSite方法代码示例

本文整理汇总了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;
        }
开发者ID:BNATENSTEDT,项目名称:PnP,代码行数:35,代码来源:SiteManager.svc.cs

示例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);
        }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:30,代码来源:AddRoleToSPSiteTaskTest.cs

示例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, "", "", "");

        }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:41,代码来源:RemoveUserFromSPSiteTaskTest.cs

示例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);

        }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:32,代码来源:RemoveRoleFromSPSiteTaskTest.cs

示例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);
     }
 }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:26,代码来源:CreateSPSiteTask.cs


注:本文中的SPSite.SelfServiceCreateSite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。