Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

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!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Get List of Users with a Module PermissionGet List of Users with a Module Permission
Previous
 
Next
New Post
2/28/2012 9:49 PM
Accepted Answer 

Here's some code from my ePrayer module which fills a drop-down list of user's in roles granted the custom "Moderate" permission. It was written against DNN 5.4.4 but should still work in DNN 6. The pattern of first getting all roles that have been granted "Moderate" permission then getting all users in those roles is the one you'll want to use. In this case the method goes one step further by filtering out those users who have already been approved as moderators and displayed in a GridView (gvModerators) on the same page.

Private Sub FillAvailableModeratorsDDL()
            Dim arrAvailable As New ArrayList
            Dim mpc As New DotNetNuke.Security.Permissions.ModulePermissionController
            Dim rc As New DotNetNuke.Security.Roles.RoleController
            Dim mp As DotNetNuke.Security.Permissions.ModulePermissionInfo
            For Each mp In DotNetNuke.Security.Permissions.ModulePermissionController.GetModulePermissions(ModuleId, TabId)
                If mp.PermissionCode = "WESNet_EPRAYER" And mp.PermissionKey = "MODERATE" Then
                    Dim RoleName As String = mp.RoleName
                    If IsDBNull(mp.RoleName) Then
                        'If mp.RoleName is null then must be individual permission so
                        Dim li As New ListItem(mp.Username, mp.UserID.ToString)
                        If Not arrAvailable.Contains(li) Then arrAvailable.Add(li)
                    Else
                        For Each ui As Entities.Users.UserInfo In rc.GetUsersByRoleName(PortalId, RoleName)
                            Dim li As New ListItem(ui.DisplayName, ui.UserID.ToString)
                            If Not arrAvailable.Contains(li) Then arrAvailable.Add(li)
                        Next
                    End If

                End If
            Next
            Dim i As Integer = arrAvailable.Count - 1
            If gvModerators.DataKeys.Count > 0 Then
                Do While i >= 0
                    Dim li As ListItem = CType(arrAvailable.Item(i), ListItem)
                    Dim j As Integer = 0
                    Do While j < gvModerators.DataKeys.Count
                        Dim dk As DataKey = gvModerators.DataKeys(j)
                        If li.Value = dk.Value.ToString Then
                            arrAvailable.Remove(li)
                            Exit Do
                        End If
                        j += 1
                    Loop
                    i -= 1
                Loop
            End If
            With ddlAvailableModerators
                .DataSource = arrAvailable
                .DataBind()
                .Items.Insert(0, New ListItem(Localize("Select_New_Moderator"), "0"))
            End With
            btnAddModerator.Enabled = arrAvailable.Count > 0
        End Sub

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
2/29/2012 9:28 AM
 
Thanks William, that got me close enough to figure it out.
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Get List of Users with a Module PermissionGet List of Users with a Module Permission


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out