user()

Returns the detailed attributes of a single user account by username. Unlike users(), this method returns complete account information including login statistics, password expiry, and MFA configuration.

1. Signature

  • Sync

  • Async

ecm.security.user(username: str) -> ECMUserAttributes | None
await ecm.security.user(username: str) -> ECMUserAttributes | None

2. Parameters

Parameter Default Description

username

Internal user name (e.g. "ROOT"). Not the GUID.

3. Return value

ECMUserAttributes instance, or None if the user was not found.

3.1. ECMUserAttributes fields

Field Type Description

id

int

Numeric user ID.

username

str

Short internal user name.

login_name

str

Login credential name used for authentication.

display_name

str

Full display name.

email

str

E-mail address.

guid

str

Globally unique identifier of the user account.

profile_id

int

Profile ID: -1 = no profile.

locked

bool

True if the account is locked.

remark

str

Optional remark.

account_type

int

Account type identifier.

flags

int

Bit-field of user flags.

lang_id

int

Language ID of the user. 0 = server default.

login_count

int

Number of times the user has logged in.

login_station

str

Name of the station from the last login.

login_time

datetime | None

Timestamp of the last login. None if the user has never logged in.

last_modified

datetime | None

Timestamp of the last account modification.

mfa_flag

int

Multi-factor authentication flag.

never_expire

bool

True if the account never expires regardless of valid_to.

change_pwd

bool

True if the user must change their password at next login.

pwd_changed

datetime | None

Timestamp of the last password change. None if the password has never been changed.

server_id

int

ID of the home server for this account.

station

str

Default station name assigned to the user.

supervisor_id

int

User ID of the supervisor. -1 if no supervisor is assigned.

valid_from

datetime | None

Account valid-from date.

valid_to

datetime | None

Account valid-to date.

4. Examples

4.1. Load a user and inspect attributes

  • Sync

  • Async

user = ecm.security.user("john")
if user:
    print(user.display_name, user.email, user.guid)
    print(f"Last login: {user.login_time}")
    print(f"Login count: {user.login_count}")
    if user.locked:
        print("Account is locked")
user = await ecm.security.user("john")
if user:
    print(user.display_name, user.email, user.guid)
    print(f"Last login: {user.login_time}")

4.2. Resolve GUID for user_groups()

  • Sync

  • Async

user = ecm.security.user("john")
if user:
    groups = ecm.security.user_groups(user.guid)
    print([g.name for g in groups])
user = await ecm.security.user("john")
if user:
    groups = await ecm.security.user_groups(user.guid)
    print([g.name for g in groups])

5. See also