= roles()
:description: Returns the ECMSystemRole values assigned to a user (mng.GetUserRoles). System roles control module access (DMS, Workflow, Admin) independently of group permissions.
:keywords: roles, mng.GetUserRoles, ECMSystemRole, system roles, DMS, Workflow, Admin
:page-tags: api, security

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.

== Signature

[tabs]
====
Sync::
+
[source,python]
----
ecm.security.roles(user_guid: str = "") -> list[ECMSystemRole]
----

Async::
+
[source,python]
----
await ecm.security.roles(user_guid: str = "") -> list[ECMSystemRole]
----
====

== Parameters

[cols="1,1,3"]
|===
|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.
|===

[NOTE]
====
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.
====

== Return value

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

== Examples

=== Check own roles

[tabs]
====
Sync::
+
[source,python]
----
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)
----

Async::
+
[source,python]
----
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")
----
====

=== Check another user's roles

Requires the `ADMIN_CONFIGURE_SECURITY` system role:

[tabs]
====
Sync::
+
[source,python]
----
user = ecm.security.user("john")
if user:
    roles = ecm.security.roles(user.guid)
    print([r.name for r in roles])
----

Async::
+
[source,python]
----
user = await ecm.security.user("john")
if user:
    roles = await ecm.security.roles(user.guid)
    print([r.name for r in roles])
----
====

== See also

* xref:api/security/users.adoc[users()] — Retrieve all user accounts
* xref:api/security/user.adoc[user()] — Retrieve attributes of a single user
