SPGlobalAdmin.ExtendVirtualServer Method (String, String, String, String, 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)
Available in Sandboxed Solutions: No
Syntax
'Declaration
<ObsoleteAttribute("SPGlobalAdmin.ExtendVirtualServer is obsolete. To create a new Web application, use the SPWebApplicationBuilder class.", _
False)> _
Public Function ExtendVirtualServer ( _
strDatabaseServer As String, _
strDatabaseName As String, _
strUserName As String, _
strPassword As String, _
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 strDatabaseServer As String
Dim strDatabaseName As String
Dim strUserName As String
Dim strPassword As String
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(strDatabaseServer, _
strDatabaseName, strUserName, strPassword, _
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(
string strDatabaseServer,
string strDatabaseName,
string strUserName,
string strPassword,
Uri uri,
bool bCreateNewAppPool,
string strAppPoolId,
bool bConfigurableAppPoolAccount,
string strAppPoolUserName,
string strAppPoolPassword
)
Parameters
strDatabaseServer
Type: System.StringA string that specifies the database server.
strDatabaseName
Type: System.StringA string that contains the name of the database.
strUserName
Type: System.StringA string that contains the user name for the administrator account. The parameter is required only if SQL authentication is used.
strPassword
Type: System.StringA string that contains the password for the administrator account. The parameter is required only if SQL authentication is used.
uri
Type: System.UriAn 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.Booleantrue to create an application pool; otherwise, false.
strAppPoolId
Type: System.StringA string that specifies an ID for the application pool.
bConfigurableAppPoolAccount
Type: System.Booleantrue to indicate that the application pool account is configurable; otherwise, false.
- strAppPoolUserName
Type: System.StringA string that specifies a user name for the administrator account of the application pool. If is true, specify one of the following values:
NetworkService
LocalService
LocalSystem
strAppPoolPassword
Type: System.StringA string that specifies a password for the administrator account of the application pool. The 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 and adds a top-level site.
This example assumes the presence of an administrative form digest in the .cs or .vb file. For information on security validation, see Security Validation and Making Posts to Update Data.
Dim globalAdmin As New SPGlobalAdmin()
Dim vServers As SPVirtualServerCollection = globalAdmin.VirtualServers
If vServers(3).State = SPVirtualServerState.NeedExtend Then
Dim uri As New System.Uri(vServers(3).Url.ToString())
Try
Dim spVServer As SPVirtualServer = _
globalAdmin.ExtendVirtualServer("Database_Server", _
"Database_Name", Nothing, Nothing, uri, False, "StsAppPool1", _
False, Nothing, Nothing)
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[3].State == SPVirtualServerState.NeedExtend)
{
System.Uri uri = new System.Uri(vServers[3].Url.ToString());
try
{
SPVirtualServer spVServer =
globalAdmin.ExtendVirtualServer("Database_Server",
"Database_Name", null, null, uri, false, "StsAppPool1",
false, null, null);
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);
}
}