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.0how to know user identity and rightshow to know user identity and rights
Previous
 
Next
New Post
1/19/2007 7:39 AM
 

I have a referenced page in a iframe module. I need to know dnn user identity and rights in this asp.net page.
i've used UserInfo currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
if(currentUser.IsInRole("administrator")){
}

DotNetNuke.Entities.Users.

but it does not work.

How can I access to the user and roles?

 
New Post
1/19/2007 12:42 PM
 
Your asp.net page inside the iFrame is not a dotnetnuke page? It needs to be at least inside the same application, otherwise the user is not authentificated and a call inside yor asp.net page returns always the current anonymous user.
 
New Post
1/23/2007 6:36 AM
 

Thank you

It worked as you said

 
New Post
1/30/2007 5:04 PM
 

Hi,

I'm new in programming and VB.Net, so pardon my lack of skills :)

I got an asp.net page using the same web.config as the DNN 4.4.1 application. I can access all the roles for the current user, but IsInRole returns false.

This code return all the roles for the current user:

Dim rc As New DotNetNuke.Security.Roles.RoleController()
Dim roles As ArrayList = rc.GetRoles()
Dim um As New DotNetNuke.Entities.Users.UserController()
Dim ui As UserInfo = UserController.GetUserByName(0, Page.User.Identity.Name.ToString())
If Not ui Is Nothing Then
  Dim uid As Integer = ui.UserID()
  Dim rr As Array = rc.GetRolesByUser(uid, 0)
  Dim r As String  For Each r In rr
    Response.Write(r &
"<br/>")
  NextEnd If 

But this does not return true:

 If ui.IsInRole("Subscribers") Then
  Response.Write("True")
End If

Again, I'm new to this, but this should work shouldn't it? Of course, I could use InStr. My wish was to use the WebControl.LoginView.

/Steinar

 
New Post
1/30/2007 5:26 PM
 

There is a reason for that.

GetuserByName does NOT get the roles information for the users role.

You could do one of two things:

1. After the first block of code before you check IsInRole:

ui.Roles = Join(rr, New Char() {";"c})

2. Use a different method to fetch the current user

UserController.GetCurerntUserInfo

Either way the user wil now have the Roles property populated which will allow IsInrole to work.

 

 


Charles Nurse
Chief Architect
Evoq Content Team Lead,
DNN Corp.

Want to contribute to the Platform project? - See here
MVP (ASP.NET) and
ASPInsiders Member
View my profile on LinkedIn
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0how to know user identity and rightshow to know user identity and rights


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