Add users in bulk to ArcGIS Server 10.1

375
2
04-25-2013 01:49 PM
MikeSchonlau
Occasional Contributor III
Does anyone know of a way to add a large number of users to ArcGIS Server 10.1 that is faster than adding them one by one with Manager?

Thanks, Mike S
Tags (2)
0 Kudos
2 Replies
RichardWatson
Frequent Contributor
Write a program which does this for you.  I believe the ArcGIS Server API is exposed via REST and you should be able to drive it.  There should be Python examples if you want to use a high level language to do this.

Another alternative would be to figure out where ArcGIS Server is storing this information and update it there directly.  In my system the users are stored in a relational database so I just update the database.
0 Kudos
MattLane
Occasional Contributor II
I worked up a little python module that does this, and a few other administrative tasks, for me. It uses httplib, urllib to communicate with REST, json module to understand responses, time module to keep up with token validity, and ConfigParser module to handle a local config file for server names etc.

The bulk of the addUser function is:
            params = urllib.urlencode({'f':'json', 'token':_token.get('token'), 'username' : uname, 'password': upwd})
            headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
            conn = httplib.HTTPConnection(i.get('s'))
            conn.request("POST", "/arcgis/admin/security/users/add", params, headers)
            response = conn.getresponse()
            s = response.read()
            data = json.loads(s)
            _responses.append({"server":i.get('s'),"result":data})
0 Kudos