Available with Standard or Advanced license.
As the geodatabase administrator, you occasionally need to see who is connected to the geodatabase and which connections are locking resources. You may even need to remove certain connections. For example, an editor may have left an edit session open, locking the data in the edit session and preventing other editors from accessing it. If there are a limited number of connections that can be made to a geodatabase, you might need to disconnect someone who failed to log out to free up a connection. Or you may want to have everyone log out so you can apply a patch to the database, restore the database, or compress the geodatabase.
If people are not present to log out themselves, you can connect to the geodatabase as the geodatabase administrator from ArcGIS Desktop or an ArcPy function and drop the connections.
To disconnect users from a geodatabase in Microsoft SQL Server, the geodatabase administrator may need additional privileges.
- The geodatabase administrator (sde) in an sde-schema geodatabase requires VIEW DEFINITION privileges on the database to see the list of connected users and must be a member of the processadmin fixed server role to disconnect users.
- If the geodatabase administrator of a dbo-schema geodatabase is the database owner, the geodatabase administrator must be added to the processadmin fixed server role to disconnect users.
First, determine who is connected to the geodatabase. If necessary, you can then remove connections.
Identify and remove connections from ArcMap
You can connect to the geodatabase as the geodatabase administrator in ArcMap to view and remove connections from within the Geodatabase Administration dialog box.
- Start ArcMap or ArcCatalog.
- Connect to the geodatabase as the geodatabase administrator.
- Right-click the database connection in the Catalog tree, point to Administration, and click Administer Geodatabase.
- Click the Connections tab.
A list is displayed showing all sessions that are currently connected to the geodatabase. Your session is displayed in italic text.
- Contact individuals and ask them to close their sessions. If you are unable to contact them and still need to disconnect them from the geodatabase, proceed with the next step.
- Right-click the specific user session you want to remove from the geodatabase and click Disconnect.
The session is immediately dropped from the geodatabase.
Identify and remove connections using ArcPy
You can run Python functions to create a geodatabase connection file for the geodatabase administrator, use that connection file to connect to the geodatabase and get a list of all current geodatabase connections, and remove a connection from the geodatabase if necessary.
- Create a database connection file by running the CreateDatabaseConnection_management function in a Python window.
In this example, a connection file (ssgdb.sde) is created in the temp folder. The connection is made to the gisprod database on the sdept4 SQL Server instance, logging in as sa.
import arcpy arcpy.CreateDatabaseConnection_management ("c:\\temp","ssgdb.sde","SQL_SERVER","sdept4","DATABASE_AUTH","sa","esayP@ss","SAVE_USERNAME","gisprod")
- Run the ListUsers function to get a list of all current connections to the gisprod geodatabase.
Pass in the connection file you created in the previous step.
##No need to import arcpy if you are running functions in the same Python window. import arcpy arcpy.ListUsers("c:\\temp\ssgdb.sde")
A list of user connections is returned.
[user(ClientName=u'PC4', ConnectionTime=datetime.datetime(2014, 2, 18, 8, 30, 19), ID=18, IsDirecConnection=True, Name=u'PUBLISHER1')] [user(ClientName=u'PC25', ConnectionTime=datetime.datetime(2014, 2, 21, 14, 10, 43), ID=33, IsDirecConnection=True, Name=u'EDITOR2')] [user(ClientName=u'PC11', ConnectionTime=datetime.datetime(2014, 2, 22, 9, 18, 26), ID=39, IsDirecConnection=True, Name=u'READER5')] [user(ClientName=u'PCA2', ConnectionTime=datetime.datetime(2014, 2, 22, 11, 21, 2), ID=41, IsDirecConnection=True, Name=u'DBO')]
- Contact individuals and ask them to close their sessions. If you are unable to contact them and still need to disconnect them from the geodatabase, proceed with the next step.
- Use the information obtained from the ListUsers function to identify which connection to remove using the DisconnectUser function.
Specify the ID of the connection to remove. Here, the connection with ID 33 is removed:
##No need to import arcpy if you are running functions in the same Python window. import arcpy arcpy.DisconnectUser("c:\\temp\ssgdb.sde",33)
The session is immediately dropped from the geodatabase.