So you want to get at the roles inside of blackpearl via the API. Well it is quite simple really and here is an example. Let's say you want to list out all the users that are members of a role.
/Get all the user names for the specified role
UserRoleManagerServer rClient = new
UserRoleManagerServer();
string sRoleName = "HR Managers";
//Build a SC Connection String
SCConnectionStringBuilder cb = new
SCConnectionStringBuilder();
cb.Host = "localhost";
cb.Port = 5555;
cb.Integrated = true;
cb.IsPrimaryLogin = true;
//Open the connection to K2
rClient.CreateConnection();
rClient.Connection.Open(cb.ToString());
//Obtain a collection of users for this role
IUserCollection roleUsers = rClient.ResolveQueue(sRoleName);
foreach (IUser user in roleUsers)
{
//Write each username to the console
Console.WriteLine(user.UserID);
}
//Close the Connection
rClient.Connection.Close();
Be aware the if these roles have within their membership any "groups", each group will be resolved internally, as a result the list returned will be the resolved users. In addition, if the role has any excluded users and/or groups these will also be removed from the list that the API returns.
Check it out, HAPPY CODING!