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.0Problem Getting GetRolesByUser.PortalIDProblem Getting GetRolesByUser.PortalID
Previous
 
Next
New Post
1/22/2009 12:36 PM
 

You might even be able to do the following (by using the public read-only property "PortalId" - since it always contains the current PortalID context under which the module is rendering itself):

Dim mUserRoles As New DotNetNuke.Security.Roles.RoleController
Dim mUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo
Return mUserRoles.GetRolesByUser(mUser.UserID, mUser.PortalId)

 
New Post
1/22/2009 1:02 PM
 

Bryan Beswick wrote

You might even be able to do the following (by using the public read-only property "PortalId" 

 

This is true, and you could also use the PortalModuleBase-supplied UserId property, 

Return mUserRoles.GetRolesByUser(mUser.UserID, mUser.PortalId)

This, though, begs the question about why you're using the RoleController at all, when you could simply (since DNN will return a stub UserInfo object on an unauthenticated request) write:
 
Return base.UserInfo.Roles()
 
There are so many ways to accomplish the same end!
 
Brandon
 

 


Brandon Haynes
BrandonHaynes.org
 
New Post
1/22/2009 2:16 PM
 

All,

Based on the complexity of the original attempt, I assumed the code was written in the context of normal "current context" information (PortalModuleBase) not being available, but -- that's just an assumption. If in fact you have PMB available - I'd definitely follow Brandon's suggestion to get the user's roles.

Take care,

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
New Post
1/22/2009 4:22 PM
 

Ian Robinson wrote

Based on the complexity of the original attempt, I assumed the code was written in the context of normal "current context" information (PortalModuleBase) not being available, but -- that's just an assumption. If in fact you have PMB available - I'd definitely follow Brandon's suggestion to get the user's roles.

That's a good bottom line (though outside of a PortalModuleBase context and within the context of a web request I still prefer UserController.GetCurrentUserInfo().Roles).  I mostly chimed in to highlight how flexible the DotNetNuke API is, and that there are plenty of ways to get at the information one requires.  Beyond that it's just a matter of taste.

Brandon 


Brandon Haynes
BrandonHaynes.org
 
New Post
1/24/2009 2:20 PM
 

Bryan, Ian, Brandon,

Thank you very much for all your help. As I can see there is really more possibilities for solution for this issue.

Kind regards,

Primoz
 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Problem Getting GetRolesByUser.PortalIDProblem Getting GetRolesByUser.PortalID


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