SPGlobalAdmin.ExtendVirtualServer method (Uri, Boolean, String, Boolean, String, String)

NOTE: This API is now obsolete.

Use the SPWebApplicationBuilder class to create a new Web application instead. (In Windows SharePoint Services 2.0 the ExtendVirtualServer method extended an Internet Information Services (IIS) Web site with SharePoint Foundation, and is maintained for backward compatibility.)

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<ObsoleteAttribute("SPGlobalAdmin.ExtendVirtualServer is obsolete.  To create a new Web application, use the SPWebApplicationBuilder class.",  _
    False)> _
Public Function ExtendVirtualServer ( _
    uri As Uri, _
    bCreateNewAppPool As Boolean, _
    strAppPoolId As String, _
    bConfigurableAppPoolAccount As Boolean, _
    strAppPoolUserName As String, _
    strAppPoolPassword As String _
) As SPVirtualServer
'Usage
Dim instance As SPGlobalAdmin
Dim uri As Uri
Dim bCreateNewAppPool As Boolean
Dim strAppPoolId As String
Dim bConfigurableAppPoolAccount As Boolean
Dim strAppPoolUserName As String
Dim strAppPoolPassword As String
Dim returnValue As SPVirtualServer

returnValue = instance.ExtendVirtualServer(uri, _
    bCreateNewAppPool, strAppPoolId, _
    bConfigurableAppPoolAccount, strAppPoolUserName, _
    strAppPoolPassword)
[ObsoleteAttribute("SPGlobalAdmin.ExtendVirtualServer is obsolete.  To create a new Web application, use the SPWebApplicationBuilder class.", 
    false)]
public SPVirtualServer ExtendVirtualServer(
    Uri uri,
    bool bCreateNewAppPool,
    string strAppPoolId,
    bool bConfigurableAppPoolAccount,
    string strAppPoolUserName,
    string strAppPoolPassword
)

Parameters

  • uri
    Type: System.Uri

    An absolute URI for the virtual server, which includes the host name, port number, and custom URL information. For example, if the URI is https://Server_Name:Port_Number/Sample_URL, when the virtual server is extended Sample_URL is included as part of the URL.

  • bCreateNewAppPool
    Type: System.Boolean

    true to create an application pool; otherwise, false.

  • strAppPoolId
    Type: System.String

    A string that specifies an ID for the application pool.

  • bConfigurableAppPoolAccount
    Type: System.Boolean

    true to indicate that the application pool account is configurable; otherwise, false.

  • strAppPoolUserName
    Type: System.String
    • A string that specifies a user name for the administrator account of the application pool. The strAppPoolUserName parameter is required only if the bConfigurableAppPoolAccount parameter is set to true.
  • strAppPoolPassword
    Type: System.String

    A string that specifies a password for the administrator account of the application pool. The strAppPoolPassword parameter is required only if the parameter is set to true.

Return value

Type: Microsoft.SharePoint.Administration.SPVirtualServer
An SPVirtualServer object that represents the extended virtual server.

Remarks

Before extending a virtual server by using the ExtendVirtualServer method, you can customize the web.config file that will be placed on the server by creating an XML file that supplements the web.config file on the current server. For information, see Working with web.config Files in Windows SharePoint Services.

Examples

The following code example extends a specified virtual server, adds a content database for the virtual server, and creates a top-level site.

Dim globalAdmin As New SPGlobalAdmin()
Dim vServers As SPVirtualServerCollection = globalAdmin.VirtualServers

If vServers(5).State = SPVirtualServerState.NeedExtend Then
    Dim uri As New System.Uri(vServers(5).Url.ToString())

    Try
        Dim spVServer As SPVirtualServer = _
          globalAdmin.ExtendVirtualServer(uri, False, "StsAppPool1", _
          False, Nothing, Nothing)
        Dim dbCollection As SPContentDatabaseCollection = _
          spVServer.ContentDatabases
        dbCollection.Add("Database_Server", "Database_Name", Nothing, _
          Nothing, 1000, 1000, 0)

        Dim sites As SPSiteCollection = spVServer.Sites
        sites.Add(spVServer.Url.ToString(), "DOMAIN\User_Alias", _
          "Email_Address")

        Catch ex As System.Exception
            Response.Write(ex.Message + ControlChars.Lf + _
              ControlChars.Lf + ex.StackTrace)
     End Try
End If
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPVirtualServerCollection vServers = globalAdmin.VirtualServers;

if (vServers[5].State == SPVirtualServerState.NeedExtend)
{
    System.Uri uri =  new System.Uri(vServers[5].Url.ToString());

    try
    {
        SPVirtualServer spVServer = 
          globalAdmin.ExtendVirtualServer(uri, false, "StsAppPool1", 
          false, null, null);
        SPContentDatabaseCollection dbCollection = 
          spVServer.ContentDatabases;
        dbCollection.Add("Database_Server", "Database_Name", null, 
          null, 1000, 1000, 0);

        SPSiteCollection sites = spVServer.Sites;
        sites.Add(spVServer.Url.ToString(), "DOMAIN\\User_Alias", 
          "Email_Address");
    }

    catch (System.Exception ex)
    {
        Response.Write(ex.Message + "\n\n" + ex.StackTrace); 
    }
}

See also

Reference

SPGlobalAdmin class

SPGlobalAdmin members

ExtendVirtualServer overload

Microsoft.SharePoint.Administration namespace