473,395 Members | 1,653 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,395 software developers and data experts.

[.NET 1.1] Authentication and cookies clarifications

Hi all,

I'm testing ASP.NET 1.1 authentications and cookies features, and I've
red tons of tutorials and articles about this, but not all is clear for me.

My goal is to create a basic site with authentication process, like my
other ASP 3.0 sites that I developed with classical session variables to
follow each user with some personal data (like role, e-mail address,
preferences, ect.).

In .NET 1.1 I understand the basic web.config settings with
<authentication> node and <authorize> and so on... I've tested the
global.asax "onauthenticationrequest" to cast an identities to principal
for use "isInRole" properties, but this hint not solve the problem of
save in temporary memory some other data for not access to database
everytime, also I want to use a database table for storing my users
data, also their role in this application.

My questions are:

1) if I use a database table, can I use "If
FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text)
Then ..."? (I don't think so, I think this is only possible with users
and passwords definition on web.config, so I've to check with an "IF
statement" the value with my datareader relative values.)

2) How can I menage efficently roles? I don't want to ask to database
the user credential every page access... I've tried a trick to add to
user name the role value with ":rolevalue" and then retrieve with a
substring method the relative values (in this case I can pass user name
and role simply, but I can't pass efficently other informations).

2.1) Can I use temporary cookies to store this informations?
2.2) Can I eventually encript this cookies (there's some builtin .NET
functions?)
2.3) Can I use sessions variables? Many people say that is not a good
idea...

3) There's a way to add other values to the cookie that ASP.NET generate
for authentication? Or I've to set another cookie for that? I see that
this auto-generated cookie is encrypted, so it would be a good and
simple possibility for my goals ;-)

4) I've tried to set up a clear-text cookie in the meaning of:
If FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text) Then
Dim cook As New HttpCookie("trialcookie")
cook.Values.Add("role", "1")
Response.Cookies.Add(cook)
FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, False)
End If
but in the protected page, now visible after this authentication, I
can't see "role" value of the cookie... why?

5) If I've two subdirectories "users" and "admins" (each contain
specific content pages), and If I can't manage group in web.config with
form authentication, how can I denied access to this specific
directories? I think I've to add code at "load" event to each page to
check user role (take by cookies, sesssion variables or other
suggestions see at top questions), in fact, I can't use <location>
node to specify group roles...
Really thanks for your patience, I think that this post can be usefull
for some other .NET newbie developer like me :-).

Nicola
Jan 20 '06 #1
2 1826
Nicola here is a good article here at :-(Which uses Database to store its
Roles and secures drirectories)
http://www.codeproject.com/aspnet/formsroleauth.asp
Hope this helps
Patrick
**Any more questions pls do post it
"Nicola Farina" <"sciagu[nospam]"@libero.it> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I'm testing ASP.NET 1.1 authentications and cookies features, and I've
red tons of tutorials and articles about this, but not all is clear for me.
My goal is to create a basic site with authentication process, like my
other ASP 3.0 sites that I developed with classical session variables to
follow each user with some personal data (like role, e-mail address,
preferences, ect.).

In .NET 1.1 I understand the basic web.config settings with
<authentication> node and <authorize> and so on... I've tested the
global.asax "onauthenticationrequest" to cast an identities to principal
for use "isInRole" properties, but this hint not solve the problem of
save in temporary memory some other data for not access to database
everytime, also I want to use a database table for storing my users
data, also their role in this application.

My questions are:

1) if I use a database table, can I use "If
FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text)
Then ..."? (I don't think so, I think this is only possible with users
and passwords definition on web.config, so I've to check with an "IF
statement" the value with my datareader relative values.)

2) How can I menage efficently roles? I don't want to ask to database
the user credential every page access... I've tried a trick to add to
user name the role value with ":rolevalue" and then retrieve with a
substring method the relative values (in this case I can pass user name
and role simply, but I can't pass efficently other informations).

2.1) Can I use temporary cookies to store this informations?
2.2) Can I eventually encript this cookies (there's some builtin .NET
functions?)
2.3) Can I use sessions variables? Many people say that is not a good
idea...

3) There's a way to add other values to the cookie that ASP.NET generate
for authentication? Or I've to set another cookie for that? I see that
this auto-generated cookie is encrypted, so it would be a good and
simple possibility for my goals ;-)

4) I've tried to set up a clear-text cookie in the meaning of:
If FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text) Then Dim cook As New HttpCookie("trialcookie")
cook.Values.Add("role", "1")
Response.Cookies.Add(cook)
FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, False)
End If
but in the protected page, now visible after this authentication, I
can't see "role" value of the cookie... why?

5) If I've two subdirectories "users" and "admins" (each contain
specific content pages), and If I can't manage group in web.config with
form authentication, how can I denied access to this specific
directories? I think I've to add code at "load" event to each page to
check user role (take by cookies, sesssion variables or other
suggestions see at top questions), in fact, I can't use <location>
node to specify group roles...
Really thanks for your patience, I think that this post can be usefull
for some other .NET newbie developer like me :-).

Nicola

Jan 21 '06 #2
Patrick.O.Ige ha scritto:
Nicola here is a good article here at :-(Which uses Database to store its
Roles and secures drirectories)


ok but for other user relate data?
Jan 21 '06 #3

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

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
4
by: Jay | last post by:
I have authentication set for my site but I need one page to be an exception case. Namely my forgot password page. How do I tell the webconfig file to authenciate all pages except one page? ...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
3
by: Joey Powell | last post by:
This message was originally posted to the aspnet.security newsgroup, but no one there has ever heard of this before. That is why I am posting this message here, so that more people will see it... ...
3
by: Peter Row | last post by:
Hi, I better get the background stuff out the way first, so here goes: - Porting a VB6 webclass app to VB.NET using HttpHandlers and FormsAuthentication - When someone visits my site...
2
by: Mike | last post by:
1. For some reason after the session has ended and the authentication cookie has expired I'm not being redirected to the login page. Insted I'm be assigned a new authentication cookie? Anyone have...
2
by: pv_kannan | last post by:
I recently found out that my authentication cookies are not expiring even though I have set the persist property to false. As a result, users are able to access the secure websites with indifferent...
1
by: Mark Olbert | last post by:
I'm building an ASPNET2 website which uses forms authentication but does not use the Microsoft-supplied membership providers (mostly because I don't want to create my own provider at this point, and...
8
by: =?Utf-8?B?TFc=?= | last post by:
Hello! I am just learning about forms authentication so please excuse this basic question. I am using .NET 1.1 and C#. I have created my web.config file and my login.aspx and the associated cs...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.