Determining via Python if a User is Logged in

514
3
04-25-2019 08:15 AM
DaveArnold2
New Contributor

I'm using the ArcGIS API for Python class arcgis.gis.User to develop a script that pulls the currently logged in users on Portal, and then dumps their user name, full name, and email to a CSV file.  The one issue I'm running into is that I can't find a way to determine if a user is currently logged in.  I can use epoch time and last login to determine how long a user has been logged in, but that doesn't tell me if they are still logged in when I run the script.  Thoughts?

0 Kudos
3 Replies
JonathanQuinn
Esri Frequent Contributor

Session information isn't stored in Portal, so there's no way to determine who is currently logged into the Portal. Checking the last login value or querying the logs for token generations is an approach, but you're right, there's no way to determine directly within the Portal whether a user is currently logged in.

If you're using IWA, maybe you can check the IIS logs on the Web Adaptor machine and see if requests have come in for a particular user within the last x seconds?

DaveArnold2
New Contributor

Thank you, Jonathan.  I didn't think it would be easy, but I wanted to make sure before I investigate further.

0 Kudos
EarlMedina1
Occasional Contributor III

Hi Dave,

I just thought I'd mention that it is possible to generate a CSV report for inactive users. In that scenario you could set a small threshold like 1 day or a few hours, perhaps. That's not quite what you're looking for but it's the next best thing.

-Earl

0 Kudos