SPGlobalAdmin.ExtendVirtualServer method (String, String, String, String, 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 ( _
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
'用途
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
)
參數
strDatabaseServer
Type: System.String字串,指定的資料庫伺服器。
strDatabaseName
Type: System.String字串,包含資料庫的名稱。
strUserName
Type: System.String包含的系統管理員帳戶的使用者名稱的字串。只有在使用 SQL 驗證,則需要參數。
strPassword
Type: System.String包含系統管理員帳戶的密碼字串。只有在使用 SQL 驗證,則需要參數。
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會指定應用程式集區的 「 管理員 」 帳戶的使用者名稱的字串。如果是true,指定下列值之一:
NetworkService
LocalService
LocalSystem
strAppPoolPassword
Type: System.String指定應用程式集區的 「 管理員 」 帳戶的密碼字串。只有當參數設定為true,則需要參數。
傳回值
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
下列程式碼範例會將延伸至指定的虛擬伺服器,並將最上層網站。
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);
}
}