Skip to main content
Version: 7.9

system.security.getUserRoles

This function is used in Python Scripting.

Description

Fetches the roles for a user from the Gateway. This may not be the currently logged in user. Requires the password for that user. If the authentication profile name is omitted, then the current project's default authentication profile is used.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.security.getUserRoles(username, password, authProfile, timeout)

Parameters

TypeParameterDescription
StringusernameThe username to fetch roles for.
StringpasswordThe password for the user.
StringauthProfileThe name of the authentication profile to run against. Optional. Leaving this out will use the project's default profile.
IntegertimeoutTimeout for client-to-gateway communication. (default: 60,000ms)

Returns

PyTuple - A list of the roles that this user has, if the user authenticates successfully. Otherwise, returns None.

Scope

Client

Code Examples

Example #1
# Fetch the roles for a given user, and check to see if the role "Admin" is in them.

reqRole = "Admin"
username = "Billy"
password= "Secret"
roles = system.security.getUserRoles(username, password)
if reqRole in roles:
# do something requiring "Admin" role.