Remove ArcGIS Server User through Python Script

4385
7
04-01-2015 01:11 PM
mpboyle
Occasional Contributor III

Is it possible to remove an ArcGIS Server user account through a python script?  I have a secured service that I'd like certain users to only have access to for a certain period of time and then remove their access.  Rather than trying to remember to remove their account, I was hoping it would be possible to create a python script which could be used with Task Scheduler to schedule a time for the script to run and remove the user.

With the REST admin having an API, I'm hoping this is possible, but am not really sure where to start.

Thanks in advance!

Tags (1)
0 Kudos
7 Replies
BlakeTerhune
MVP Regular Contributor

ArcGIS REST API - Remove User

ArcGIS for Server (Windows) - Scripting with the ArcGIS REST API

Sorry, I haven't done this before so getting the info is as much as I know. Anything more and I'm learning right with you. Here's some other useful information I've found...

ArcGIS Server Administration Toolkit - 10.1+

arcpy/AdministeringArcGISServerwithPython_DS2014 · GitHub

RyanN
by
New Contributor II

Matthew - We are also looking for a solution to manage/delete user profiles in ArcGIS Server via scripts or other tools as a part of map-survey we plan to deploy.  In our case, we want to completely remove the user profiles after our survey is complete.

Blake - thanks for the resources as a place to start.

Have you guys come up with any solutions since your posting?

0 Kudos
mpboyle
Occasional Contributor III

Ryan,

I found the ArcREST toolbox on GitHub to be a good resource for this.  It provides a wizard driven interface to create and delete users.  Using ModelBuilder you can create a model using the 'Create a User' or 'Delete User' script tools.  You can then include the model as part of a python script by calling your toolbox and model, which can then be used along with Task Scheduler if you wanted to automate the task at a certain date/time.

I've also found the Server Admin toolbox (mentioned above by Blake) to be another good interface driven way of interacting with ArcGIS Server.

Below is a screenshot of the tools available in both, with the 'Create User' and 'Delete User' tools highlighted...

servertools.JPG

RyanN
by
New Contributor II

Thanks Matt.  Unfortunately the Create/Delete user in the ArcRest toolkit was created only for ArcGIS Online Users - not users from an onsite ArcGIS Server.  Unless I'm missing something (which is definitely possible!), I think it might take quite a bit of re-engineering to make it work for ArcGIS Server.

The Server Admin Toolkit does look like it has nice tools for managing ArcGIS Server, but doesn't seem to have anything for managing users.

0 Kudos
RyanN
by
New Contributor II

One way to delete users en masse from an ArcGIS Server site that uses the ArcGIS Server identity store is to access the machine the server is installed on - from here, go to \config-store\security\users.  Select the users that need removal/deletion from the site. 

I know this is not at all an elegant solution, but it is quick and easy, and seemingly accomplishes what I need with out any adverse side effects.  I'd be curious if anyone from esri or otherwise could come up with a reason why exactly this might be an ill-advised hack other than it not being good practice to modify anything manually in the config store of an arcgis server?

0 Kudos
WesMiller
Regular Contributor III

You could use ArcGIS Help (10.2, 10.2.1, and 10.2.2) to revoke the users privileges.

0 Kudos
BlakeTerhune
MVP Regular Contributor

Unfortunately, arcpy.ChangePrivileges_management() is just for database users in SDE, not ArcGIS Server.