roles()

Returns the system roles assigned to a user as a list of ECMSystemRole enum values. Without a user_guid, the roles of the currently logged-in user are returned.

1. Signature

  • Sync

  • Async

ecm.security.roles(user_guid: str = "") -> list[ECMSystemRole]
await ecm.security.roles(user_guid: str = "") -> list[ECMSystemRole]

2. Parameters

Parameter Default Description

user_guid

""

GUID of the user whose roles should be returned. An empty string (default) returns the roles of the currently logged-in user.

Querying the roles of another user requires the ADMIN_CONFIGURE_SECURITY system role. Unknown role IDs (not present in the ECMSystemRole enum) are silently omitted.

3. Return value

List of ECMSystemRole enum values. Empty list when no roles are assigned.

4. Examples

4.1. Check own roles

  • Sync

  • Async

from ecmind_blue_client.ecm import ECMSystemRole

roles = ecm.security.roles()
if ECMSystemRole.ADMIN_CONFIGURE_SECURITY in roles:
    print("User may configure security settings")

for role in roles:
    print(role.name, role.value)
from ecmind_blue_client.ecm import ECMSystemRole

roles = await ecm.security.roles()
if ECMSystemRole.ADMIN_CONFIGURE_SECURITY in roles:
    print("User may configure security settings")

4.2. Check another user’s roles

Requires the ADMIN_CONFIGURE_SECURITY system role:

  • Sync

  • Async

user = ecm.security.user("john")
if user:
    roles = ecm.security.roles(user.guid)
    print([r.name for r in roles])
user = await ecm.security.user("john")
if user:
    roles = await ecm.security.roles(user.guid)
    print([r.name for r in roles])

5. See also

  • users() — Retrieve all user accounts

  • user() — Retrieve attributes of a single user