ARTIFACTORY: How to get a list of inactive Artifactory users?

ARTIFACTORY: How to get a list of inactive Artifactory users?

AuthorFullName__c
Fadi Rouhana
articleNumber
000005578
FirstPublishedDate
2023-02-14T14:20:12Z
lastModifiedDate
2025-07-20
VersionNumber
1

In order to keep track of the account used to authenticate against the platform, some Artifactory admins may want to keep an eye on the activity of the users in the JFrog Platform, either to remove unused users or to keep an eye on the overall user activity. 

For this, you can use the simple Python script below, which takes the JFrog URL and the login information for a system administrator and outputs a file named “users_activity.json” with a sorted list of all users and the time they last logged in.

[Important]
Please note that the script below only takes into account the login date, therefore, it will not reflect the activity of users that authenticate against the REST API or other authentication methods.
 

import json
import requests

def get_users_login():
    res = {}
    # get a list of all users from Artifactory
    url = "https://<JFROG_URL>/artifactory”
    r = requests.get(
        url + "/api/security/users",
        auth=("<ADMIN_USER>", "<ADMIN_PASSWORD"),
        headers={"content-type": "text/plain"},
    )
    # get each user's details
    for u in json.loads(r.text):
        d = requests.get(
            url + "/api/security/users/" + u["name"],
            auth=("<ADMIN_USER>", "<ADMIN_PASSWORD>"),
            headers={"content-type": "text/plain"},
        )
        if "lastLoggedIn" in json.loads(d.text):
            res[u["name"]] = str(json.loads(d.text)["lastLoggedIn"])

    # sort the list based on 'lastLoggedIn' field
    sorted_res = {k: v for k, v in sorted(res.items(), key=lambda item: item[1])}
    with open("users_activity.json", "w") as out:
        json.dump(sorted_res, out)


get_users_login()



Example “users_activity.json” file: 

{
    "demo_user": "2021-08-02T08:13:33.098Z",
    "david": "2022-03-09T08:45:16.259Z",
    "admin": "2023-02-09T11:29:09.995Z",
    "example@jfrog.com": "2023-02-01T15:07:26.004Z"
}