SPGlobalAdmin.SetAdminPort 方法
请注意:此 API 现在已过时。
若要更改的管理网站的端口号,更新与管理由SPAdministrationWebApplication.Local,返回的 Web 应用程序关联的SPIisSettings对象,并调用SPWebApplication类的Provision方法。(在Windows SharePoint Services 2.0SetAdminPort方法设置的端口号的管理虚拟服务器。
命名空间: Microsoft.SharePoint.Administration
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
<ObsoleteAttribute("To change the port of the administration site, update the SPIisSettings associated with SPAdministrationWebApplication.Local and call SPWebApplication.Provision().", _
False)> _
Public Sub SetAdminPort ( _
nPort As Integer, _
bSsl As Boolean _
)
用法
Dim instance As SPGlobalAdmin
Dim nPort As Integer
Dim bSsl As Boolean
instance.SetAdminPort(nPort, bSsl)
[ObsoleteAttribute("To change the port of the administration site, update the SPIisSettings associated with SPAdministrationWebApplication.Local and call SPWebApplication.Provision().",
false)]
public void SetAdminPort(
int nPort,
bool bSsl
)
参数
nPort
类型:System.Int32指定的端口号 32 位整数。
bSsl
类型:System.Boolean使用true来指定该安全套接字层 (SSL) 协议 ;否则为false。
备注
使用SetAdminPort方法不会更新开始菜单链接,除非是单线程单元 (STA) 线程。
示例
下面的示例演示如何使用SetAdminPort方法。如果此方法不是可能的该应用程序必须创建新的线程并ApartmentState属性设置为STA,如第一个示例所示。
如果代码运行在 ASPX 页中,page 指令中的ASPCompat属性必须设置为TRUE— 例如, <%@Page ASPCompat="TRUE"%>。
Public Class Admin
<STAThread()>
Public Shared Sub Main()
Dim globalAdmin As New SPGlobalAdmin()
globalAdmin.SetAdminPort(8080, False)
End Sub 'Main
End Class 'Admin
public class Admin
{
[STAThread]
public static void Main()
{
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
globalAdmin.SetAdminPort(8080, false);
}
}
Public Class Admin
Dim setAdminPortThread As New Thread(New ThreadStart(AddressOf SetAdminPort))
setAdminPortThread.ApartmentState = ApartmentState.STA
setAdminPortThread.Start()
setAdminPortThread.Join()
Public Sub SetAdminPort()
Dim globalAdmin As New SPGlobalAdmin()
Try
globalAdmin.SetAdminPort(2003, False)
Finally
globalAdmin.Close()
End Try
End Sub 'SetAdminPort
End Class 'Admin
public class Admin
{
Thread setAdminPortThread = new Thread(new ThreadStart(SetAdminPort));
setAdminPortThread.ApartmentState = ApartmentState.STA;
setAdminPortThread.Start();
setAdminPortThread.Join();
public void SetAdminPort()
{
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
try
{
globalAdmin.SetAdminPort(2003, false);
}
finally
{
globalAdmin.Close();
}
}
}