SPGlobalAdmin.ExtendVirtualServer method (Uri, Boolean, String, Boolean, String, String)
NOTE: This API is now obsolete.
而是建立新的 Web 應用程式使用SPWebApplicationBuilder類別。(在Windows SharePoint Services 2.0ExtendVirtualServer方法延伸SharePoint Foundation,與網際網路資訊服務 (IIS) 網站和維護回溯相容性。)
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
<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
Type: System.Uri虛擬伺服器,包括主機名稱、 連接埠號碼和自訂 URL 資訊絕對 URI。例如,如果 URI 是https://Server_Name:Port_Number/Sample_URL時的虛擬伺服器擴充Sample_URL , 是加入為之 url。
bCreateNewAppPool
Type: System.Boolean若要建立的應用程式集區 ; true否則,請false。
strAppPoolId
Type: System.String指定應用程式集區識別碼的字串。
bConfigurableAppPoolAccount
Type: System.Booleantrue表示應用程式集區帳戶是可設定 ;否則,請false。
- strAppPoolUserName
Type: System.String- 會指定應用程式集區的 「 管理員 」 帳戶的使用者名稱的字串。只有bConfigurableAppPoolAccount參數設為truestrAppPoolUserName參數是必要的。
strAppPoolPassword
Type: System.String指定應用程式集區的 「 管理員 」 帳戶的密碼字串。只有當參數設定為truestrAppPoolPassword參數是必要的。
傳回值
Type: 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.
Examples
下列程式碼範例會延伸至指定的虛擬伺服器,將內容資料庫的虛擬伺服器,並建立最上層網站。
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);
}
}