Visual Studio .NET - User.IsInRole works locally but not on server?

Asked By Paddy Mac
22-Nov-06 07: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.  User.IsInRole works anywhere.

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.

 

  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  more information

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  got this problem solved
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
help
Frequently asked Interview Questions in ADO.Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B B) What is concept of Boxing and Unboxing ? (B) What is the difference between VB.NET and C#? (I) what is the difference between System exceptions and Application exceptions? (I)What is CODE Access security? (I)What is a satellite assembly? (A) How to prevent my .NET DLL to be decompiled? (I) what is the difference between Convert.toString and .toString () method assembly in GAC how do we make a choice? (A)What is CodeDom? Chapter 2: NET Interoperability (I) How can we use COM Components in .NET? (I) We have developed the COM wrapper do we have to still register the COM
Interview Questions for .NET Framework This article is specially for the users those are in development or want to be a .net developer • To test a Web Service you must create a windows application or web application to consume this service? It is True / False? FALSE How many classes can a single.NET DLL contain? Answer1: As many Answer2: One or more What are good ADO.NET object(s) to replace the ADO Recordset object? The differences includes In ADO, the in memory representation of data is the recordset. In ADO.net, it is the dataset A recordset looks like a single table in ADO In contrast, a dataset is a collection of one or more tables in ADO.net ADO is designed primarily for connected access ADO net the disconnected access to the database is used In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter
visual studio installation problem Actually, my OS is Windows Xp with service pack2.I added service pack3 to install visual studio2010.after that i tryed to installed, but am getting SETUP FAILED due to "Windows XP is not installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates Microsoft Visual F# 2.0 Runtime was not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio Macro Tools was not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates .NET Framework 4 Multi-Targeting Pack was not attempted to be installed. [08 / 10 / 11, 14:26:01] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 Professional - ENU was not attempted to be installed. [08 / 10 / 11, 14:26
Interface and Abstract Class Hai, When do we go for Interface. . When do we go for Abstract Class. . .Give one example Today i faced one interview . . He asked this question.I want answer with Example Thanks in Advance Abstract Class :: - It cannot defines all the methods - It has subclass. - Here, Subclass is useless - A class can be extend an abstract class Interface :: - It defines all the methods - It must have implementations by other classes, But there http: / / kyapoocha.com / c-sharp-interview-questions / what%E2%80%99s-the-difference-between-an-interface-and-abstract-class-5 / http: / / www.dotnetuncle.com / Difference / 4_abstract_class_interface.aspx Hope this helps. HI An interface contains signatures of methods , delegates or events . The implementation of the methods is done in the class that implements the interface, as shown in the following example: interface ISampleInterface { void SampleMethod(); } class ImplementationClass : ISampleInterface { / / Explicit interface member implementation: void ISampleInterface.SampleMethod() { / / Method implementation. } static void Main() { / / Declare
Role Based Security in .NET I read the article about Role based security for VB.NET http: / / www.eggheadcafe.com / articles / 20020418.asp but the download source code has an error on Forms Authentication, Membership and Role providers. I am building a Windows application in VB.NET under VS2005 using both SQL Server 2000 and 2005 and I am looking for a settings occurs less often. What's wrong with the intrinsic support for this in the .NET framework? The basics for role-based security can be found in the .NET framework. However, implementing it in your ASP.NET application can be somewhat painful. Because of the stateless nature of web applications, you are security. Another article on role based security with forms authentication. . . Introduction Forms Authentication in ASP.NET can be a powerful feature. With very little code and effort, you can have a based security in Forms Authentication is one thing Microsoft left out in this round for .NET, but they didn't leave you high-and-dry. The mechanisms are there, they're