Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

RoleController

Return to previous page

  • 4/7/2015
  • 7058 Views

Comments

7058 Views

RoleController

Last updated long time ago

Comments

Common

(Enter the content of this article below)

Advanced

 

Background

The RoleController class is the primary way for working with roles programatically with the DotNetNuke framework. The API documentation for this (and the rest of the public API) is available with the API documentation at API documentation.

Accessing the current users roles

There are a number of ways to work with the current users roles. We can use the UserController class and access the current user like so:

Dim userInfo = UserController.GetCurrentUserInfo()

Dim userRoles = userInfo.Roles

alternatively we can use the rolecontroller methods, though we will have to provide additional information. In the example below the code is on a control that inherits from PortalModuleBase so we have access to the PortalID

Dim userRoles As New DotNetNuke.Security.Roles.RoleController

Dim userInfo As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo

Dim showroles As String = ""
For Each i As String In userRoles.GetRolesByUser(userInfo.UserID, me.PortalID)
showroles += i.ToString() & ","
Next

Additional references:
Create a New User and Add to Specific Role Programatically
Contents
No sections defined
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out