次の方法で共有


SPWebServer Class

Represents a front-end Web server in a server farm.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPWebServer

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class SPWebServer

Dim instance As SPWebServer
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPWebServer

Remarks

Use the WebServers property of the SPGlobalConfig class to get the collection of Web servers in a server farm. Use an indexer to return a single Web server from the collection. For example, if the collection is assigned to a variable named myWebServers, use myWebServers[index] in C#, or myWebServers(index) in Visual Basic, where index is the index number of the server in the collection.

Examples

The following code example displays information in a console application about all the front-end Web servers in the Windows SharePoint Services deployment.

Dim globalAdmin As New SPGlobalAdmin()
Dim globalConfig As SPGlobalConfig = globalAdmin.Config
Dim webServers As SPWebServerCollection = globalConfig.WebServers
Dim webServer As SPWebServer

For Each webServer In webServers

    Console.WriteLine("Name: " & webServer.Name & ControlChars.Lf & _
        "Address: " & webServer.Address & ControlChars.Lf & _
        "Port: " & webServer.AdminPort.ToString() & ControlChars.Lf & _
        "AdminPortURL: " & webServer.AdminPortUrl.ToString() & ControlChars.Lf & _
        "ID: " & webServer.Id.ToString() & ControlChars.Lf & ControlChars.Lf)

Next webServer

Console.ReadLine()
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPGlobalConfig globalConfig = globalAdmin.Config;

SPWebServerCollection webServers = globalConfig.WebServers;

foreach (SPWebServer webServer in webServers)
{
    Console.Write("Name: " + webServer.Name +
        "\nAddress: " + webServer.Address +
        "\nPort: " + webServer.AdminPort.ToString() +
        "\nAdmin Port URL: " + webServer.AdminPortUrl +
        "\nID: " + webServer.Id.ToString() + "\n\n");
}

Console.ReadLine();

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPWebServer Members

Microsoft.SharePoint.Administration Namespace