473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HttpContext.Current.User.IsInRole

Hi,
In my asp.net app I am using this code:

FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(
1,
lcred.UserName,
DateTime.Now,
DateTime.Now.AddMinutes(ldExpiration),
false,
lsRoles
);

lsRoles is a string with all roles (separated with "|").

When I later use the HttpContext.Current.User.IsInRole method it works fine
on my developer machine but not on my production machine... what can be wrong.

Thanks
Dec 12 '05 #1
1 6774
From what you've shown us, you aren't doing enough to get it work (not sure
why it's working in dev).

Take a look at:
http://www.codeproject.com/aspnet/AspNetCustomAuth.asp

But you should be getting the roles (from the cookie if they are there, or
from wherever else if they aren't) and creating a new IPrincipal user which
you assign to the Context.User.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Julia" <Ju***@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Hi,
In my asp.net app I am using this code:

FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(
1,
lcred.UserName,
DateTime.Now,
DateTime.Now.AddMinutes(ldExpiration),
false,
lsRoles
);

lsRoles is a string with all roles (separated with "|").

When I later use the HttpContext.Current.User.IsInRole method it works
fine
on my developer machine but not on my production machine... what can be
wrong.

Thanks

Dec 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MJB | last post by:
I know I can get the current username through the System.Environment class, but I can't seem to find where I can retrieve the user's role / permission level (i.e. Admin, power user, etc). If...
4
by: Mark | last post by:
hey, i'm trying to get the current windows user and the groups they are in. Intergrated windows auth on and annoymous access turned off on IIS. However when trying to compile the following code...
3
by: John Dalberg | last post by:
I am setting the HttpContext.Current.User in the Application_AuthenticateRequest event in global.asax.cs. When I use the IsInRole function in a web page, it works fine. So far so good. (Note that...
8
by: Oliver Rainer | last post by:
Hi, I have the following problem... Pre-requisites: Installation of an Asp.net webservice on a IIS5 server (win2k). Anonymous access is not allowed, only using windows authentication (intranet...
8
by: Mark White | last post by:
Hey everyone I'm having a great deal of problems finding this information through google and yahoo, so I turn to you on this. I have a Windows app running on XP. I am able to caputre the...
1
by: Peter Bons | last post by:
Hi, I have a question, I know that I can determine whether an user belongs to a certain AD group. But what if I want to check for a serie of users? I could use the DirectoryServices classes...
4
by: Doogie | last post by:
Hi, I am using HttpContext.Current.User.Identity.Name to get a user id from a web application. I then use that as part of a name of a cookie I'm writing. 30 minutes later I do a refresh of this...
3
by: Madhur | last post by:
Hello I am delivering an asp.net 2.0 application to my customer. I need to know, If I need to check for the condition of HttpContext.Current to be null in my business logic. I have extensively...
13
by: bproddu | last post by:
Hi, I'm using Forms authentication for my web app. I've a custom Principal class that I would like to set to the HttpContext.Current.User after the Membership.ValidateUser() passes. I'm able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.