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/17/2009 1:30 PM
 

Sorry for the confusion.  Let me explain the rest of the story (doesn't there always seem to be a "rest of the story"?)  I have a DNN module (IndooGrid) that I use for tons of things.  I noticed that one of their new features (the ability to behave differently depending on whether the user is a member of a particular role) doesn't seem to always work properly when I am on my main portal (which turns-out to be #26.)  I did as much debugging as I could without having their source code - which included turning-on a capture of all SQL commands submitted to the server.  I noticed that their code was checking what roles I was a member-of on PortalID 0 - recall I was logged into 26.

I reported this as a bug via their forum. The developer's response was that they didn't think it was a bug because they were simply using the built-in DNN mechanism to determine roles.  They attached a snippit of their code that does this checking.  I constructed my own stand-along module to verify their code and determined that, indeed, it is checking PortalID 0.  That leads me to this forum post ... I am essentially trying to determine if there is something wrong with my configuration (so I can get this feature of Indoo working on my system) or if there is a bug in their code so I can demonstrate it to them and they can fix it and ship me a patched version of their module.

(Hopefully this all makes more sense now.)  This may sound like I am going a little "above and beyond" as a client of theirs but I use this module for a bunch of things and, other than this one issue, it is a great tool.  I need this new feature of theirs to work quickly so I can release some functionality that uses it.  The code they sent me that they are using to check to see what roles the user is in is:

Dim mRoles As New DotNetNuke.Entities.Users.OnlineUserInfo

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, mRoles.PortalID)

 

Let me know if their code is wrong and I will "break the news" to them.  Sorry if my previous posts were too cryptic - I was hoping that it would be a quick and easy answer for y'all.

 
New Post
1/19/2009 12:38 PM
 

Hey Bryan,

This code will only ever return a portal id "0" because they are creating a new OnlineUserInfo object, and then directly asking for it's PortalID property without doing anything with that object. Furthermore, from what I can tell, there is no valid use of OnlineUserInfo outside of the DNN core.

Typically, these values (User ID and Portal ID) would be retrieved simply from PortalModuleBase, which provides a slew of useful "current context" information. I suspect that in the context of this code, they do not have PortalModuleBase readily available, so they are trying to work around it by getting the current context from the current HttpContext.

Long story short, there are two options:

  1. If you have current context (e.g. your class inherits from PortalModuleBase) use me.UserID and me.PortalID
  2. If you don't have current context, just use mUser.PortalID instead of mRoles.PortalID above.

Hope that helps,

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
New Post
1/21/2009 8:02 AM
 

Ian,

I cannot find documentation about this topic - can you help me with this, please?

I assume this is better code:

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)


How I see function returns roles for current user and user's portal. How should I modify code that function will return roles for current user and current portal? Thanks in advance for any help.

Kind regards,

 

Primoz

 
New Post
1/21/2009 9:35 AM
 

Pril,

When I see the code in the current version of IndooGrid execute, it is asking SQL for the roles for the user within PortalID 0.  I suspect you can just test the above new code to verify that mUser.PortalID is in fact returning the current PortalID (you should obviously test this from a child portal.)  If mUser.PortalID actually returns the correct PortalID then you should be in good shape.

Please let me know (through your online forum) when we have a fix for Indoo.

Thanks again for an excellent (and versatile) module!

 
New Post
1/21/2009 5:55 PM
 

Hey Primoz,

I think Bryan is right - testing it out to make sure it is working is the best way to know - However, from glancing through it I believe that will work just fine.

Take care,

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
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