HOW TO
The last login dates are helpful in determining the list of active users in ArcGIS Enterprise portal and ArcGIS Online. Administrators have the required privileges to view audit logs and remove non-active users to free up licenses for new users. The last login dates can be determined using ArcGIS API for Python.
Complete the steps below to determine the last login date in ArcGIS Enterprise portal and ArcGIS Online using ArcGIS API for Python.
import arcgis import time from arcgis.gis import GIS
ArcGIS Enterprise portal
gis = GIS("https://domain.esri.com/portal", username="user1", password="pass1", verify_cert=False) print("connected")
ArcGIS Online
gis = GIS("https://arcgis.com", username="username", password="password") print("connected")
a_users = gis.users.search(query='', max_users=200) a_users
for a_user in a_users: if a_user. lastLogin != -1: last_accessed = time.localtime(a_user. lastLogin/1000) print(str(a_user. fullName) + " was last active on: {}/{}/{}\n".format(last_accessed[0], last_accessed[1], last_accessed[2])) else: print(str(a_user. fullName) + " has never logged in.\n")
The following shows the full script:
import arcgis import time from arcgis.gis import GIS #For Portal for ArcGIS gis = GIS("https://domain.esri.com/portal", username="user1", password="pass1", verify_cert=False) #For ArcGIS Online gis = GIS("https://arcgis.com", username="username", password="password") print("connected") a_users = gis.users.search(query='', max_users=200) a_users for a_user in a_users: if a_user. lastLogin != -1: last_accessed = time.localtime(a_user. lastLogin/1000) print(str(a_user. fullName) + " was last active on: {}/{}/{}\n".format(last_accessed[0], last_accessed[1], last_accessed[2])) else: print(str(a_user. fullName) + " has never logged in.\n")
The image below shows the result of the above script.
Unterstützung durch ArcGIS-Experten anfordern
Esri Support App herunterladen