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.
Solved! Go to Solution.
The link to what Neil mentions Esri/portalpy · GitHub
Portalpy is a Python module that allows you to administer Portal for ArcGIS and ArcGIS Online.
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