search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

View Other Visual Studio .NET Posts   Ask New Question 
User.IsInRole works locally but not on server?
Paddy Mac posted at Wednesday, November 22, 2006 7:05 AM

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 at 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.

 

 
  re:User.IsInRole works locally but not on server?
K Pravin Kumar Reddy replied to Paddy Mac at 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

 
more information
Paddy Mac replied to Peter Bromberg at 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

 

 

 
  got this problem solved
Paddy Mac replied to Peter Bromberg at 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")