API Questions on Kentico API.
Version 6.x > API > Displaying User Roles in a list View modes: 
User avatar
Member
Member
Conrad - 10/30/2012 6:00:56 PM
   
Displaying User Roles in a list
What would be the best way to filter and display all the roles for a particular user in a drop-down list?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/3/2012 1:06:59 PM
   
RE:Displaying User Roles in a list
Hello.

Where exactly you want to show this?

In any case, I would recommend to develop a custom web part and get these roles via our API. It returns DataSet, so you can bind it to your drop-down list as usual in ASP.NET. If you are not familiar with this topic, you can find more info here.

Best Regards,
Radek Macalik

User avatar
Member
Member
Conrad - 11/3/2012 1:27:21 PM
   
RE:Displaying User Roles in a list
I want to show the users of our intranet what roles they have been assigned. I've put it in a custom web part that shows a limited version of their profile. Using examples in the source code, I tried what you suggested but I'm fairly new to ASP.NET and data binding. I mainly wanted to confirm what part of the API and which control to use(if kentico had a special drop down control for data binding or not).

I think this will help me work out the bugs. Thank you for helping me find the right reference material.

Much appreciated.

User avatar
Member
Member
Conrad - 11/6/2012 5:01:49 PM
   
RE:Displaying User Roles in a list
I can see how you get a table with either UserRoleInfoProvider.GetUserRoles() or RoleInfoProvider.GetRoles(). I'm proficient with SQL, so I understand the parameters that have to be included. What I'm having trouble with is that I know I would have to join the CMS_UserRole table to the CMS_Role table in order to get the role_name column associated with a certain userID but I don't know how to do an inner join with the functions I stated above.

Data binding aside, how would you get user role names from a list or table containing role IDs for a specific user?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/20/2012 5:44:57 AM
   
RE:Displaying User Roles in a list
Hello.

The GetUserRoles method calls CMS.User.SelectRoles query, which already joins CMS_Role and CMS_UserRole tables, so you can use fifth parameter („Columns to get“) to directly specify what columns you want to retrieve in the DataSet. It can be any column(s) from both tables, including RoleName.

I am not sure how did you get list of RoleID’s without possibility to get RoleNames as well?

Best Regards,
Radek Macalik