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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0.isinrole help.isinrole help
Previous
 
Next
New Post
4/18/2007 7:28 PM
 

I need some help. I need to check to see if a user in in a role. This is not for the user currently viewing the page. I can get it to work with me.userinfo.IsInRole("Paid Member")

My code----------

Dim myUser As UserInfo
myUser = UserController.GetUser(PortalId, intuserid, True)

If myUser.IsInRole("Paid Member") Then
strtemp += "Current<br>"
End If

 
New Post
4/18/2007 9:43 PM
 

What error are you getting?

 
New Post
4/18/2007 11:59 PM
 

IsInRole is broken for any but the current active user - the Roles() array property that the IsInRole method uses internally is not being hydrated.

U need to use the RolesController methods to test if the user is in a role - am not at my dev box at the moment or I would put up some code..

Westa

 
New Post
4/19/2007 8:55 AM
 

Thanks for the help. I used the code below and got it working.

bolnl = False
For Each objUser2 In objRoles2.GetUsersByRoleName(0, "Paid Member")
If objUser2.UserID = objUser.UserID Then
bolnl = True
End If
Next

 
New Post
4/19/2007 10:06 AM
 

As you found the Roles property of the UserInfo object only gets populated for the current user (and then not reliably it seems!). So, you can populate it in your own code then use the UserInfo method IsInRole as you intended. For a portal with many users, this should be much more efficient then iterating through the UserInfo objects returned by GetUsersByRoleName:

Dim rc As New DotNetNuke.Security.Roles.RoleController
myUser.Roles = rc.GetRolesByUser(myUser.UserId, PortalId)
If myUser.IsInRole("Paid Member") Then

End If

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
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0.isinrole help.isinrole help


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