cancel
Showing results for 
Search instead for 
Did you mean: 

Using API to set roles for users by Role Name? get RoleID by name?

Former Member
0 Kudos

Hi,

I am trying to add users to MDM and set the Roles for them.

I can do this with the RoleID by number, like this, but I need to set roles for users by role name.

Currently I can do this:

RoleId role1 = new RoleId(5);

RoleId role2 = new RoleId(10);

cmd.User.RoleIds = new RoleId[] { role1,role2 };

But I need to do this more like:

RoleId role1 = new RoleId("Admin");

Is this possible? I can't find a function to get a RoleID by name.

---

Found this:

GetRoleListCommand grlc = new GetRoleListCommand(repSessionCtx);

grlc.Session = repsessiontext;

grlc.execute();

RoleProperties[] roles = grlc.getRoles();

Edited by: Wardell Castles on Jul 28, 2010 4:21 PM

Edited by: Wardell Castles on Jul 28, 2010 5:15 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member206388
Contributor
0 Kudos

Hi Wardell.

There is no direct API to fetch the RoleId by name. As you mentioned, you can use the roleproperties to fetch the ID and Name.

GetRoleListCommand grlcommand = new GetRoleListCommand(repSessionCtx);

grlcommand.Session = repsessiontext;

grlcommand.execute();

RoleProperties[] roles = grlcommand.getRoles();

for(int i=0;i<roles.length();i++){

RoleProperties rp = roles<i>;

rp.getName(); // You can get the name of the role

rp.getId() // Also you can get the id of the role.

}

Is this what you are looking?

If you have found a solution for your query, please close the thread by saying completed.

Thanks

Bala