How to connect to ArcGIS Server with the SOM


Summary This topic demonstrates how to connect to ArcGIS Server via the Server Object Manager (SOM). You must define an identity (user account) present in the agsusers or agsadmin groups on the SOM machine. Once connected, you can access existing services as server objects and work with them via server context. Server object types include "MapServer", "GeocodeServer", "GeometryServer", "GeodataServer", "ImageServer", "GlobeServer", "GPServer" and "", an empty server context.

  1. Setup an application with the Web ADF and ArcGIS Server libraries using the sample description as a guide.
  2. Set the username, password, and domain variables to a user account in the agsuser or agsadmin groups on the SOM. Define the servername variable to be the machine on which the SOM is running.
  3. Set the serverobjectname to the name of an ArcGIS Server map service.
[C#]
// Using the ArcGIS Connection library
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(userName, password,
    domain);
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection;
agsServerConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection
    (serverName, identity);
agsServerConnection.Connect();

// Using the ArcGIS Server API
ESRI.ArcGIS.Server.IServerObjectManager serverObjectManager =
    agsServerConnection.ServerObjectManager;
string serverType = "MapServer";
ESRI.ArcGIS.Server.IServerContext serverContext =
    serverObjectManager.CreateServerContext(serverObjectName, serverType);

// If pooled, release context per request.  If non-pooled, release context per session.
serverContext.ReleaseContext();
[VB.NET]
' Using the ArcGIS Connection library
Dim identity As ESRI.ArcGIS.ADF.Identity = New ESRI.ArcGIS.ADF.Identity(userName, password, domain)
Dim agsServerConnection As ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection
agsServerConnection = New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(serverName, identity)
agsServerConnection.Connect()

' Using the ArcGIS Server API
Dim serverObjectManager As ESRI.ArcGIS.Server.IServerObjectManager = agsServerConnection.ServerObjectManager
Dim serverType As String = "MapServer"
Dim serverContext As ESRI.ArcGIS.Server.IServerContext = serverObjectManager.CreateServerContext(serverObjectName, serverType)

' If pooled, release context per request.  If non-pooled, release context per session.
serverContext.ReleaseContext()