Look at the code below and if you try to run this code then it will give error while creating a site because sharepoint doesn't find super admin account
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(url))
{
SPSiteCollection workspaces = site.WebApplication.Sites;
using (SPSite workspaceSite = workspaces.Add("URL", "Name", "Description", 1033, "BDR#0", SPContext.Current.Web.CurrentUser.LoginName, SPContext.Current.Web.CurrentUser.Name, SPContext.Current.Web.CurrentUser.Email))
{
return workspaceSite.ID;
}
}
});
So the workaround of this problem is to get the default site administrator of current site collection and put it in new site collection
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(url))
{
SPUser administrator = site.RootWeb.SiteAdministrators[0];
SPSiteCollection workspaces = site.WebApplication.Sites;
using (SPSite workspaceSite = workspaces.Add("URL", "Name", "Description", 1033, "BDR#0", administrator.LoginName, administrator.Name, administrator.Email))
{
return workspaceSite.ID;
}
}
});
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(url))
{
SPSiteCollection workspaces = site.WebApplication.Sites;
using (SPSite workspaceSite = workspaces.Add("URL", "Name", "Description", 1033, "BDR#0", SPContext.Current.Web.CurrentUser.LoginName, SPContext.Current.Web.CurrentUser.Name, SPContext.Current.Web.CurrentUser.Email))
{
return workspaceSite.ID;
}
}
});
So the workaround of this problem is to get the default site administrator of current site collection and put it in new site collection
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(url))
{
SPUser administrator = site.RootWeb.SiteAdministrators[0];
SPSiteCollection workspaces = site.WebApplication.Sites;
using (SPSite workspaceSite = workspaces.Add("URL", "Name", "Description", 1033, "BDR#0", administrator.LoginName, administrator.Name, administrator.Email))
{
return workspaceSite.ID;
}
}
});
BDR#0 is the template Name for document center site. You can use any of the following in site creation process:
ID | Name | Display group |
0 | GLOBAL#0 | Global template |
1 | STS#0 | Team Site |
1 | STS#1 | Blank Site |
1 | STS#2 | Document Workspace |
2 | MPS#0 | Basic Meeting Workspace |
2 | MPS#1 | Blank Meeting Workspace |
2 | MPS#2 | Decision Meeting Workspace |
2 | MPS#3 | Social Meeting Workspace |
2 | MPS#4 | Multipage Meeting Workspace |
3 | CENTRALADMIN#0 | Central Admin Site |
4 | WIKI#0 | Wiki Site |
7 | BDR#0 | Document Center |
9 | BLOG#0 | Blog |
15 | SGS#0 | Group Work Site |
16 | TENANTADMIN#0 | Tenant Admin Site |
20 | SPS#0 | SharePoint Portal Server Site |
21 | SPSPERS#0 | SharePoint Portal Server Personal Space |
22 | SPSMSITE#0 | Personalization Site |
30 | SPSTOC#0 | Contents area Template |
31 | SPSTOPIC#0 | Topic area template |
32 | SPSNEWS#0 | News Site |
33 | SPSNHOME#0 | News Site |
34 | SPSSITES#0 | Site Directory |
36 | SPSCOMMU#0 | Community area template |
38 | SPSREPORTCENTER#0 | Report Center |
39 | CMSPUBLISHING#0 | Publishing Site |
40 | OSRV#0 | Shared Services Administration Site |
47 | SPSPORTAL#0 | Collaboration Portal |
50 | SRCHCEN#0 | Enterprise Search Center |
51 | PROFILES#0 | Profiles |
52 | BLANKINTERNETCONTAINER#0 | Publishing Portal |
53 | BLANKINTERNET#0 | Publishing Site |
53 | BLANKINTERNET#1 | Press Releases Site |
53 | BLANKINTERNET#2 | Publishing Site with Workflow |
54 | SPSMSITEHOST#0 | My Site Host |
56 | ENTERWIKI#0 | Enterprise Wiki |
61 | visprus#0 | Visio Process Repository |
90 | SRCHCENTERLITE#0 | Basic Search Center |
90 | SRCHCENTERLITE#1 | Basic Search Center |
2000 | SRCHCENTERFAST#0 | FAST Search Center |
2764 | ACCSRV#0 | Access Services Site |
2764 | ACCSRV#1 | Assets Web Database |
2764 | ACCSRV#3 | Charitable Contributions Web Database |
2764 | ACCSRV#4 | Contacts Web Database |
2764 | ACCSRV#6 | Issues Web Database |
2764 | ACCSRV#5 | Projects Web Database |
3100 | PPSMASite#0 | PerformancePoint |
3200 | BICenterSite#0 | Business Intelligence Center |
14483 | OFFILE#0 | (obsolete) Records Center |
14483 | OFFILE#1 | Records Center |
No comments:
Post a Comment