User created date

Hi there,

Is there any collections in mongoDB we can check when the user was created?

It is stored in the logs shown on the dashboard but only for a short time, these logs are rotated and not recoverable. MongoDB ObjectID’s contain a timestamp and the user certificate will show a timestamp in the Not Before field. The user ID is viewable by holding shift and clicking the green Organization label on the users page.

The user certificates can take time to generate, to keep the interface and new single sign-on authentication fast these are pre-generated. The server will pool 6 users for each organization as set by sudo pritunl set app.user_pool_size 6. If there isn’t frequent user creation these times could be significantly sooner than when the actual user was created but it would represent the earliest possible time the user existed. Below is Python code to extract the time from an ObjectID.

from bson.objectid import ObjectId
import datetime

def extract_timestamp_from_objectid(object_id_str):
    try:
        object_id = ObjectId(object_id_str)
        timestamp = object_id.generation_time
        return timestamp
    except Exception as e:
        print(f"Error: {e}")
        return None

object_id_str = "591ac2723eff2141a2182c2"
timestamp = extract_timestamp_from_objectid(object_id_str)

if timestamp:
    print(f"Timestamp: {timestamp}")
1 Like