Select to view content in your preferred language

ArcGIS Enterprise Portal - ArcGIS Pro Logins using ArcGIS API for Python

273
1
03-14-2024 03:51 PM
babarsac
New Contributor III

Esri Support has a nice Python snippet allowing you to pull a list of your Enterprise users and that last time they logged in.

 

 

import arcgis
import time
from arcgis.gis import GIS

gis = GIS("https://domain.mycorp.com/portal", username="user1", password="pass1", verify_cert=False)

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")

 

 

 

Is there something similar in the API that can be used to see that last time a user authenticated from ArcGIS Pro? It would allow us to easily enumerate which users are no longer using ArcGIS Pro or have never used it even though they are assigned a license.

GIS Discord Channel
https://disboard.org/server/769917190182404127
0 Kudos
1 Reply
babarsac
New Contributor III

I've made some headway on this issue so I want to shared what I have so far.

from arcgis.gis import GIS
import pandas as pd

gis = GIS("https://domain.mycorp.com/portal", username="user1", password="pass1", verify_cert=False

pro_license = gis.admin.license.get('ArcGIS Pro')

pd.set_option('display.max_colwidth', None)

pro_license.report

 

This creates a Pandas dataframe  with the results of all usage of ArcGIS Pro and extensions. I compared these results to the users last Enterprise login date and they don't match up. Which means I'm truly getting the last time a user authenticated from ArcGIS Pro.

Of course there's a but....

These results only show Pro users who have ArcGIS Pro assigned to them as an Add-In license. If the user gets their Pro license from a User Type such as GIS Professional Advanced then they are not included in the report above. If anyone has a bit more insight  into the gis.admin.license package I'd appreciate it.

 

GIS Discord Channel
https://disboard.org/server/769917190182404127
0 Kudos