SPGlobalAdmin.ExtendVirtualServer 方法 (Uri, Boolean, String, Boolean, String, String)

请注意:此 API 现在已过时。

使用SPWebApplicationBuilder类而是创建新的 Web 应用程序。(在Windows SharePoint Services 2.0ExtendVirtualServer方法扩展SharePoint Foundation,Internet 信息服务 (IIS) 网站和所维护的用于向后兼容性。

命名空间:  Microsoft.SharePoint.Administration
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
<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
用法
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
)

参数

  • uri
    类型:System.Uri

    对于虚拟服务器,包括主机名、 端口号和自定义 URL 信息绝对 URI。例如,如果 URI 是https://Server_Name:Port_Number/Sample_URL,如果虚拟服务器已扩展Sample_URL是作为一部分包含的 url。

  • bCreateNewAppPool
    类型:System.Boolean

    true创建应用程序池。否则为false。

  • strAppPoolId
    类型:System.String

    一个字符串,指定应用程序池的 ID。

  • bConfigurableAppPoolAccount
    类型:System.Boolean

    true来指示应用程序池帐户进行配置。否则为false。

  • strAppPoolUserName
    类型:System.String
    • 一个字符串,指定的应用程序池的管理员帐户的用户名。仅当bConfigurableAppPoolAccount参数设置为true,则需要strAppPoolUserName参数。
  • strAppPoolPassword
    类型:System.String

    一个字符串,指定的应用程序池的管理员帐户的密码。仅当该参数设置为true,则需要strAppPoolPassword参数。

返回值

类型:Microsoft.SharePoint.Administration.SPVirtualServer
一个代表扩展虚拟服务器的SPVirtualServer对象。

备注

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.

示例

下面的代码示例扩展指定的虚拟服务器,添加内容数据库的虚拟服务器,并创建首要网站。

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); 
    }
}

另请参阅

引用

SPGlobalAdmin 类

SPGlobalAdmin 成员

ExtendVirtualServer 重载

Microsoft.SharePoint.Administration 命名空间