473,797 Members | 3,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why do we need more code in Application_Aut henticateReques t()?

Hello, friends,

I am implementing a role based authentication (Forms authentication) for our
web app using .net 1.1. I read the paper:
http://msdn.microsoft.com/library/de...SecNetHT04.asp

However, what I could not understand was: After adding a new cookie with
user's roles,

string encryptedTicket = FormsAuthentica tion.Encrypt(au thTicketWithRol eInfo);
HttpCookie authCookie =
new HttpCookie(Form sAuthentication .FormsCookieNam e,
encryptedTicket );
Response.Cookie s.Add(authCooki e);
Response.Redire ct( FormsAuthentica tion.GetRedirec tUrl(
txtUserName.Tex t,
false ));

why one still should "Construct GenericPrincipa l and FormsIdentity Objects"
in Application_Aut henticateReques t(), like the follows?

authTicket = FormsAuthentica tion.Decrypt(au thCookie.Value) ;
string[] roles = authTicket.User Data.Split(new char[]{'|'});
FormsIdentity id = new FormsIdentity( authTicket );
GenericPrincipa l principal = new GenericPrincipa l(id, roles);
Context.User = principal;

I thought Response.Cookie s.Add(authCooki e) already included all info for IIS
to check. Can we skip the above source code in
Application_Aut henticateReques t()? Why?

Thanks a lot for your help.

Apr 21 '06 #1
1 2007
I'm not completely sure what your overall intentions are with the forms
authentication, but I would use the second part to load named roles
into the genericPrincipa l object so that my forms authentication would
support different roles having access to different directories. That
way I can specify role access to directories and files (compiled pages)
in the web.config file instead manually coding the access. It also
assigns your current context user to that ticket and roles in case you
wanted to access who you are dealing with from code somewhere.

-Darrin

Apr 21 '06 #2

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

Similar topics

0
3543
by: Mike Kingscott | last post by:
Hi there, Getting into ASP.Net finally, looks good but I'm having a bit of trouble here. I'm protecting my web site via form-based security (I won't go into the ins and outs, suffice to say it's all in one web.config file and not amazing). Basically, I'm holding a list of roles in a database for each user. Once the user has got past the login form, the Application_AuthenticateRequest fires. In there, I'm doing a database lookup on the...
11
1732
by: VB Programmer | last post by:
PLEASE HELP.... I'm having trouble. In my login form after I've verified the username/password are valid I do this: Select Case iMyPrivilege Case 0 Dim arrRoles() As String = {"guest"} Context.User = New System.Security.Principal.GenericPrincipal(User.Identity, arrRoles) Case 1
1
1621
by: Homa | last post by:
Hi, I am using a role-based Forms Authentication. I have several directories that have different levels of authorization. When I try to access another directory, the page bounce me back to the login page everytime. After I re-login, I can access the page. I can't figure out what happened. I saved the roles to the User so when I access another page, they should able to see that before they bounce me out.
0
272
by: Nugs | last post by:
Hey there again, Well I am still having this problem with my forms authentication. My previous post describes my problem. But I have another question and thought I would post a new topic for it. In my last post I mentioned the following note: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/h tml/SecNetch13.asp]
2
2913
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public users). If user is from intranet, web server should recognize it and application should create additional options in controls regarding groups the user belongs to. If user is from extranet it should be logged in as anonymous and a link to login page...
1
5143
by: the friendly display name | last post by:
I am using .net 1.1 In the global.asax.cs file, there is this entry: protected void Application_AuthenticateRequest(Object sender, EventArgs e) as far as I know, it is wired with the FormsAuthentication_OnAuthenticate event.
2
1240
by: Tim::.. | last post by:
Can someone please tell me how I edit this code so it works with an OleDB... Thanks Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) ' Fires upon attempting to authenticate the use If Request.IsAuthenticated Then
3
7629
by: Noremac | last post by:
My google skills must be dwindling. I am trying to determine how in ASP.NET 2.0 I can get the ReturnUrl querystring variable in Forms Authentication to contain the absolute url. Just like others that have posed this question, we are an enterprise environment that has multiple websites across multiple servers and we are trying to setup Web SSO for our public internet site that will be accessible by our clients. ASP.NET seems to have...
0
1855
by: sloan | last post by:
I've been reading this article: http://msdn2.microsoft.com/EN-US/library/aa302401.aspx Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication (the article is for 1.1) (i'm using 2.0) The article is good. Then you get to the part about:::::::::::::
0
9537
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10469
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10209
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.