RoleController

Return to previous page

  • 4/7/2015
  • 2688 Views

Comments

2688 Views

RoleController

Last updated 6 years 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

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out