check_user_account()
Checks whether a user can log in with the given password, using the same criteria as the enaio® enterprise-manager. This is the real credential check: the password is compared against the stored password of the account (unlike check_password_complexity(), which only evaluates the password rule).
Beyond the password the job also answers whether the account exists, whether it is locked and how long the password is still valid.
|
The session user needs the |
|
Failed attempts count towards the account lockout exactly like a real login, and a successful call resets the counter. The threshold is not readable through the API, so throttle the attempts yourself - a loop over candidate passwords locks the account. |
1. Signature
-
Sync
-
Async
ecm.security.check_user_account(username: str, password: str) -> ECMUserAccountCheck
await ecm.security.check_user_account(username: str, password: str) -> ECMUserAccountCheck
2. Parameters
| Parameter | Default | Description |
|---|---|---|
|
required |
Login name of the account, e.g. |
|
required |
The plaintext password to check (or an |
|
The server manual lists |
3. Return value
ECMUserAccountCheck:
| Attribute | Type | Description |
|---|---|---|
|
|
Outcome of the check, see the table below. |
|
|
Internal user name ( |
|
|
Authentication method, e.g. |
|
|
Remaining validity within the configured |
|
|
|
|
|
|
ECMUserAccountStatus:
| Value | Code | Meaning |
|---|---|---|
|
|
Account exists, is not locked, password matched. |
|
|
No account with that login name. |
|
|
The account was just locked by too many failed attempts. |
|
|
Wrong password, another attempt is possible. |
|
|
The account was already locked, login is not possible. |
A wrong password, an unknown user and a locked account raise no exception - they are expected
outcomes of a login check and come back as a status. The server reports them as job errors instead
of the documented Action values 2/4/5; the method translates those error codes into the
matching status. Any other server error stays an error.
Only Action = 0 counts as success. A missing or unknown value is a rejection, so that a changed
server response cannot become an open door.
4. Errors
| Exception | Cause |
|---|---|
|
|
|
The session user lacks the |
|
Subclass raised by |
5. Examples
5.1. Check credentials
-
Sync
-
Async
from ecmind_blue_client.ecm import ECMUserAccountStatus
check = ecm.security.check_user_account("john", "S3cret!")
if check.login_possible:
print(f"login possible as {check.username} via {check.login_method}")
if check.password_expired:
print("password has expired and must be changed")
elif check.password_expires_in_days > 0:
print(f"password expires in {check.password_expires_in_days} days")
elif check.status is ECMUserAccountStatus.WRONG_PASSWORD:
print("wrong password")
elif check.status is ECMUserAccountStatus.USER_UNKNOWN:
print("unknown user")
else:
print("account locked")
from ecmind_blue_client.ecm import ECMUserAccountStatus
check = await ecm.security.check_user_account("john", "S3cret!")
if check.login_possible:
print(f"login possible as {check.username} via {check.login_method}")
elif check.status is ECMUserAccountStatus.WRONG_PASSWORD:
print("wrong password")
5.2. Report expiring passwords
for user in ecm.security.users():
check = ecm.security.check_user_account(user.username, service_passwords[user.username])
if check.login_possible and 0 <= check.password_expires_in_days <= 14:
print(f"{check.username}: password expires in {check.password_expires_in_days} days")
6. Server-side settings
Expiry and lockout behaviour are governed by four parameters in the enaio® enterprise-manager (server properties, section Login):
| enterprise-manager | Registry entry | Meaning |
|---|---|---|
Password validity period |
|
The period in days for which a password is valid; |
Warning before the validity period ends |
|
The number of days before expiry from which the user gets a warning at login. Default: |
Security level |
|
Behaviour on failed logins: default |
One-time password |
|
New users are created with a one-time password and must change it right at their first login.
Default: |
The parameters are described in the enaio® administrator documentation under the server
properties, the job parameters Action and PwdExpires in the enaio® server-api reference.
7. Notes
-
The check runs on the existing session; the job does not open a session for the checked user, it only returns the verdict.
-
Never pass the password in plaintext yourself: the server decodes the value and reports plaintext as "Invalid password". This is why the method always does the encoding itself.
-
Whether failed attempts lock the account is governed by the security level (
Login\SecurityLevel, default0= no restriction; higher values close the application or lock the account after three failed attempts). The counter is per account, other users are unaffected. -
A lockout from failed logins is not visible in the account attributes: user() keeps reporting
locked = Falsewhile this check returnsACCOUNT_LOCKED.
8. See also
-
check_password_complexity() — Check the password rule (not a credential check, needs no role)
-
roles() — Check the user’s system roles
-
user() — Account attributes including
locked,valid_to,change_pwd -
update_user() — Unlock an account or set a password