User.IsInRole works locally but not on server?

Asked By Paddy Mac
22-Nov-06 07:05 AM
Earn up to 0 extra points for answering this tough question.

Hi,

can anyone please help me out?

User.IsInRole works on the locally, but when I put it on the server it doesn't work?

Thanks

Paddy

  User.IsInRole works anywhere.

Peter Bromberg replied to Paddy Mac
22-Nov-06 07:24 AM

As long as

1) There is an authenticated User based on the Authentication type configured.

2) The user has been assigned a Role.

So, you need to find out what is different about your server configuration. You haven't given us any real information, so if you want more help, you will need to provide it.

 

  re:User.IsInRole works locally but not on server?

K Pravin Kumar Reddy replied to Paddy Mac
22-Nov-06 07:27 AM

hello

check the link below so u will find some solution

The IPrincipal interface, which the GenericPrincipal class we used above implements, has a method called IsInRole(), which takes a string designating the role to check for. So, if we only want to display content if the currently logged-on user is in the "Administrator" role, our page would look something like this:

reference

http://www.codeproject.com/aspnet/formsroleauth.asp?df=100&forumid=6668&exp=0&select=1482068

  more information

Paddy Mac replied to Peter Bromberg
22-Nov-06 08:50 AM

I should have provided the below information.

I'm using Windows integrated Authenication, and my roles are on active directory.  I am also using impersonate = true. I just want to hide a panel if a user does not belong to the role 'DL-ITG'.  When I browse this locally it works fine.

On the server it knows who I am but it's not picking up my role?

My code:

Protected Sub View2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles View2.Load

If Me.type_of_ritaRadioList.SelectedValue = "New user account" Then

If User.IsInRole("DL-ITG") Then

Me.At_behalfPanel.Visible = True

Response.Write("true" + User.Identity.Name.ToString())

Else

Me.At_behalfPanel.Visible = False

Response.Write("false" + User.Identity.Name.ToString())

End If

End If

End Sub

 

 

  got this problem solved
Paddy Mac replied to Peter Bromberg
22-Nov-06 09:10 AM

The server was on a different domain so I had to put the domain in the role lookup.

eg

User.IsInRold("mydomain\DL-ITG")

 

Create New Account