Hi all
Does anyone know of a way to use arcpy to obtain a list of the current users in a Portal?
I'm trying to set up a python script that reconciles versioned datasets each night, and instead of hardcoding the usernames to search for in the versions I would prefer that the script got the list of current users directly from Portal.
Any ideas?
Cheers,
-Paul
Solved! Go to Solution.
Get portalpy from esri/github.
There is a portal.get_org_users() method to the portal object.
And a bunch of other useful portal functions
The link to what Neil mentions Esri/portalpy · GitHub
and description...
Portalpy is a Python module that allows you to administer Portal for ArcGIS and ArcGIS Online.
Thanks Neil
That's exactly what I needed - didn't know it existed but after a quick look I can see it becoming very useful.
Cheers,
-Paul
Using the ArcGIS API for Python:
from arcgis.gis import GIS
# replace the your URL, your username and your password with the relevant
# information for your organization
# you must use an admin account to generate users
gis = GIS("https://<your URL> /portal", "<your username>","<your password>")
users = gis.users.search("*")
for i in users:
print(i.username, " " , i.email)
# see https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user
# for other things you can print out for each user
# see https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#usermanager
# for ways to search and sort users