Admin.CreateSite Method (Administration)
Creates a site collection.

Web Service: AdministrationWeb Reference: http://<AdminSite>/_vti_adm/Admin.asmx
Syntax

Visual Basic (Declaration)
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/CreateSite", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function CreateSite ( _
    Url As String, _
    Title As String, _
    Description As String, _
    Lcid As Integer, _
    WebTemplate As String, _
    OwnerLogin As String, _
    OwnerName As String, _
    OwnerEmail As String, _
    PortalUrl As String, _
    PortalName As String _
) As String
Visual Basic (Usage)
Dim instance As Admin
Dim Url As String
Dim Title As String
Dim Description As String
Dim Lcid As Integer
Dim WebTemplate As String
Dim OwnerLogin As String
Dim OwnerName As String
Dim OwnerEmail As String
Dim PortalUrl As String
Dim PortalName As String
Dim returnValue As String

returnValue = instance.CreateSite(Url, Title, Description, Lcid, WebTemplate, OwnerLogin, OwnerName, OwnerEmail, PortalUrl, PortalName)
C#
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/CreateSite", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public string CreateSite (
    string Url,
    string Title,
    string Description,
    int Lcid,
    string WebTemplate,
    string OwnerLogin,
    string OwnerName,
    string OwnerEmail,
    string PortalUrl,
    string PortalName
)

Parameters

Url

String that contains the absolute URL of the site collection.

Title

String that contains the display name of the site collection.

Description

String that contains a description for the site collection.

Lcid

Integer that specifies the locale identifier (LCID) for the site collection.

WebTemplate

String that contains the name of the site template to use for creating the site collection. The following table shows the values for the default site definitions included in an installation of Windows SharePoint Services.

Value

Site Definition

STS#0

Team Site

STS#1

Blank Site

STS#2

Document Workspace

MPS#0

Basic Meeting Workspace

MPS#1

Blank Meeting Workspace

MPS#2

Decision Meeting Workspace

MPS#3

Social Meeting Workspace

MPS#4

Multipage Meeting Workspace

BLOG#0

Blog Site

WIKI#0

Wiki Site

OwnerLogin

String that contains the user name (DOMAIN\User_Alias) of the owner.

OwnerName

String that contains the display name of the owner.

OwnerEmail

String that contains the e-mail address of the owner.

PortalUrl

String that contains the URL of a portal site for the site collection.

PortalName

String that contains the name of a portal site for the site collection.

Return Value

String that contains the URL of the new site collection.
Remarks

The account that accesses this web service must be a member of the Farm Administrators group in the Central Administration site. Note that the server's local Administrators group is in the Farm Administrators group by default.

To access the Admin service and its methods, set a Web reference to http://Virtual_Server_Name:Port_Number/_vti_adm/Admin.asmx.

NoteNote:

This service is only available on the Central Administration Web application, and not in any of the content Web applications.

Example

The following code example creates a new site collection on the specified server.

Visual Basic
Dim admService As New Web_Reference_Folder_Name.Admin()
admService.Credentials = System.Net.CredentialCache.DefaultCredentials
Try
    admService.CreateSite("http://Server_Name/sites/SiteCollection_Name", _
        "Title", "Description", 1033, "STS#0", _
        "Domain_Name\User_Alias", "User_Display_Name", _
        "User_E-mail", "", "")
    Catch ex As System.Web.Services.Protocols.SoapException
        MessageBox.Show("Message:" + ControlChars.Lf + ex.Message + 
            ControlChars.Lf + _
            "Detail:" + ControlChars.Lf + ex.Detail.InnerText + 
                ControlChars.Lf + _
            "StackTrace:" + ControlChars.Lf + ex.StackTrace)
End Try
C#
Web_Reference_Folder_Name.Admin admService = 
    new Web_Reference_Folder_Name.Admin();
admService.Credentials= System.Net.CredentialCache.DefaultCredentials;
try
{
    admService.CreateSite("http://Server_Name/sites/SiteCollection_Name",
        "Title", "Description", 1033, "STS#0", 
        "Domain_Name\\User_Alias","User_Display_Name",
        "User_E-mail","","");
}
catch (System.Web.Services.Protocols.SoapException ex)
{
    MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + 
        ex.Detail.InnerText + 
        "\nStackTrace:\n" + ex.StackTrace);
}
See Also

Tags :


Page view tracker