| User.IsInRole works anywhere. |
| Peter Bromberg replied to Paddy Mac on Wednesday, November 22, 2006 7: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.
|
| Reply Reply Using Power Editor |
| Peter Bromberg is a C# MVP, MCP, and .NET expert who has worked in banking, financial and telephony for over 20 years. Pete focuses exclusively on the .NET Platform, and currently develops SOA and other .NET applications for a Fortune 500 clientele. Peter enjoys producing digital photo collage with Maya,playing jazz flute, the beach, and fine wines. You can view Peter's UnBlog and IttyUrl sites. Please post questions at forums, not via email! |  |
|
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| re:User.IsInRole works locally but not on server? |
K Pravin Kumar Reddy provided a rated reply to Paddy Mac on Wednesday, November 22, 2006 7: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
|
| Reply Reply Using Power Editor |
| K Praveen Kumar Reddy
MCTS. |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| more information |
| Paddy Mac replied to Peter Bromberg on Wednesday, November 22, 2006 8: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
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| got this problem solved |
Paddy Mac provided a rated reply to Peter Bromberg on Wednesday, November 22, 2006 9: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")
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|