Skip to main content

Users.GetRolesAsync

Description

The API gets the assigned list of roles for the specified user Id from the connected Control Room.

Signature [C#]

Task<List<RoleInfo>> GetRolesAsync(int userId)

Properties

Input

PropertyDescription
userIdSpecify the user Id to retrieve the role information.

Output

PropertyDescription
Task<List<RoleInfo>>Returns assigned roles information of a specified user.

Remarks

Use GetRolesAsync API to get the list of all assigned roles for specified user Id from the connected Control Room.

Example

C#
public void GetRoles()
{
IControlRoomContext context = LoginControlRoom("RegularBuild", "BasicAuth");
int userId = 1;

var roles = Task.Run(() => context.Users.GetRolesAsync(userId)).Result;
foreach (RoleInfo roleInfo in roles)
Console.WriteLine("Role Name: " + roleInfo.RoleName);
}
C#
public IControlRoomContext LoginControlRoom()
{
IControlRoomContext context;
string connectionString;

connectionString = "ServerUrl=https://demo.onnitellibuddies.com;UserName=demoadmin;Password=password";
context = new ControlRoomContext(connectionString);

context.Open();
return context;
}