UserRoleAdd

You can use the UserRoleAdd function to assign one or more roles to an Optiva user within a specific lab context. This function adds users to security roles and grants them role-based permissions and access rights.

When to use

You can use this function to:

  • Assign one or more roles to an Optiva user.
  • Automate user role management.

When not to use

You cannot use this function when the access collection security is active.

Syntax

int UserRoleAdd(string UserCode, string LabCode, string RolesList)

Parameters

Parameter Type Required Description
UserCode string Yes The user code or user name that identifies the Optiva user to whom roles will be assigned.
LabCode string Yes The lab code that identifies the lab context for the role assignment. For example, "GLOBAL" or "PLANT01".
RolesList string Yes A single role name or a semicolon-separated list of role names to assign to the user.

Return Value

The application returns a value greater than zero (0) if the operation is successful. Otherwise, the operation fails.

Impact

  • Adds the user to the specified role or roles within the lab context.
  • The user gains the permissions associated with the assigned role or roles.

Prerequisites

  • The target user must exist in the system.
  • The specified roles must exist in the system.

Examples

Example 1
Assign a single role to a user.
UserRoleAdd("FSI", "GLOBAL", "ADMIN");
Example 2
Assign multiple roles to a user.
UserRoleAdd("FSI", "GLOBAL", "RL_TEST;RL_BDL");