SPGlobalAdmin.SetAdminPort method
NOTE: This API is now obsolete.
To change the port number of the administration site, update the SPIisSettings object associated with the administration Web application that is returned by SPAdministrationWebApplication.Local, and call the Provision method of the SPWebApplication class. (In Windows SharePoint Services 2.0 the SetAdminPort method set the port number for the administration virtual server.)
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
<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 _
)
'Usage
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
)
Parameters
nPort
Type: System.Int32A 32-bit integer that specifies the port number.
bSsl
Type: System.Booleantrue to specify that Secure Sockets Layer (SSL) protocol is used; otherwise, false.
Remarks
Using the SetAdminPort method does not update the start menu link unless the thread is a single-threaded apartment (STA) thread.
Examples
The following examples show how to use the SetAdminPort method. If this approach is not possible, the application must create a new thread and set the ApartmentState property to STA, as in the first example.
If the code is running in an ASPX page, the ASPCompat attribute in the page directive must be set to TRUE—for example, <%@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();
}
}
}