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.0Deep Down Authentication QuestionDeep Down Authentication Question
Previous
 
Next
New Post
8/26/2009 12:32 PM
 

I'm trying to integrate the security of a DNN portal and an external system. The external system is already set up to check for role membership using the IPrincipal scheme. It appears that DNN does not completely populate the user context because the following code always returns False no matter what value is used for rolename:

HttpContext.Current.User.IsInRole("rolename")

For the life of me I can't find where in the DNN core the User property of HttpContext.Current is set, despite having been through all the code associated with logging in, and the roles stuff in the MembershipModule HttpModule. I would like to see the code to understand what I would be interfering with if I were to set it myself, for example in a custom membership provider.

Does anyone know where in the core this property gets set?

Has anyone every tried manipulating it?

 
New Post
8/27/2009 5:26 AM
 

Perhaps you should try:

 

Dim objUserInfo As UserInfo = UserController.GetCurrentUserInfo

then:

objUserInfo .IsInRole("blablabla")

 
New Post
9/5/2009 6:39 AM
Accepted Answer 

Thanks for the response, but I'm trying to get the existing code outside of DNN to work as is.

I've managed to do it, so I document that here in case anyone else wants to know.

Firstly, the question wasn't a particularly good one. ASP.NET ITSELF manages HttpContext.Current.User, persisting User.Name and User.IsAuthenticated between page cycles using the security token it saves in a cookie. However, it does not persist role memberships, so that is all you have to add for this to work.

I created an extremely simple HttpModule to populate the roles on each request from data that DotNetNuke makes available. This is simply a case of a line like the following:

HttpContext.Current.User = New GenericPrincipal(HttpContext.Current.User, UserController.GetCurrentUserInfo.Roles)

Then any tests on HttpContext.Current.User.IsInRole("rolename") work perfectly.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Deep Down Authentication QuestionDeep Down Authentication Question


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