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

Help me with Login and user roles please.

This is a simplified version of my site.

There are Premium users who have access to the Premium directory.
Anyone else attempting to access it should be logged and then
redirected to the Premium.aspx - which explains the advantages of
being a Premium member and provides examples of content.

The default page for site visitors is "News/Default.aspx" but only
those with cookies set should go there otherwise visitors need to
login to access the important pages in the site (everything else apart
from the error pages and Premium.aspx).

Every single site visitor needs to be recorded. Browser agent, IP-
address are logged for everyone.
Q1: When a user first arrives at the site, where is the best place to
determine whether they are a valid user? Is this best done in
Session_Start()?

Q2: If a user bookmarks a page I want them to go directly to it next
time (provided they are in a suitable role). How does ASP.NET know
when to bypass the Login page (presumably it gets the cookie and
checks the user roles)?

Q3: Following on from Q2, how does ASP.NET know when to go to the
defaultUrl? Where is the logic done for that and what about the
ReturnUrl - if there is one?

Q4: At what stage does all this security checking take place and if I,
as web-site author, want to interrupt it where do I interrupt it?

Q5: Is there a routine in Global.asax that allows one to override the
system security and if not so then why not so?

Q6: Is the detail regarding the ASP.NET roles and security explained
anywhere (I do mean in detail)? Following on from that, I'm not
really interested in tutorials telling one how to set up security -
I'm interested in how it works and what I can do about it when it
doesn't work as I intend.

Q7: What is the best way of debugging these problems? Setting a
breakpoint followed by start debugging is useless because by the time
the page loads the security sytem has already by-passed the page which
I have bookmarked - which is niether loginUrl nor defaultUrl. For
instance when the user has a url book-marked, for some annoying reason
the security system decides that the user should go to the defaultUrl
- how would I change that and debug what was going on?
<system.web>

<authentication mode="Forms">
<forms name="myWebSite" loginUrl="Login.aspx" defaultUrl="News/
Default.aspx" protection="All" cookieless="AutoDetect"/>
</authentication>

<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false"
timeout="5"/>

</system.web>

<location path="Premium">
<system.web>
<authorization>
<allow roles="Premium"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

<location path="Premium.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

Apr 19 '07 #1
2 2068
Well, as I've said many times before on here, we use forms authentication
with attributes that ensure that users are both logged in and in the correct
role to carry out the action they are attempting. It works well for us, and
means we can get what we want with minimal coding. In fact all our code is
pretty much the standard code you will see if you look up Forms
Authentication on msdn.

If I wanted to keep a site secure, I wouldn't rely on cookies at the expense
of getting users to authenticate. I'd want a new authentication for every
new session.

Just my 2c. YMMV.
Peter
"mark4asp" <ma******@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
This is a simplified version of my site.

There are Premium users who have access to the Premium directory.
Anyone else attempting to access it should be logged and then
redirected to the Premium.aspx - which explains the advantages of
being a Premium member and provides examples of content.

The default page for site visitors is "News/Default.aspx" but only
those with cookies set should go there otherwise visitors need to
login to access the important pages in the site (everything else apart
from the error pages and Premium.aspx).

Every single site visitor needs to be recorded. Browser agent, IP-
address are logged for everyone.
Q1: When a user first arrives at the site, where is the best place to
determine whether they are a valid user? Is this best done in
Session_Start()?

Q2: If a user bookmarks a page I want them to go directly to it next
time (provided they are in a suitable role). How does ASP.NET know
when to bypass the Login page (presumably it gets the cookie and
checks the user roles)?

Q3: Following on from Q2, how does ASP.NET know when to go to the
defaultUrl? Where is the logic done for that and what about the
ReturnUrl - if there is one?

Q4: At what stage does all this security checking take place and if I,
as web-site author, want to interrupt it where do I interrupt it?

Q5: Is there a routine in Global.asax that allows one to override the
system security and if not so then why not so?

Q6: Is the detail regarding the ASP.NET roles and security explained
anywhere (I do mean in detail)? Following on from that, I'm not
really interested in tutorials telling one how to set up security -
I'm interested in how it works and what I can do about it when it
doesn't work as I intend.

Q7: What is the best way of debugging these problems? Setting a
breakpoint followed by start debugging is useless because by the time
the page loads the security sytem has already by-passed the page which
I have bookmarked - which is niether loginUrl nor defaultUrl. For
instance when the user has a url book-marked, for some annoying reason
the security system decides that the user should go to the defaultUrl
- how would I change that and debug what was going on?
<system.web>

<authentication mode="Forms">
<forms name="myWebSite" loginUrl="Login.aspx" defaultUrl="News/
Default.aspx" protection="All" cookieless="AutoDetect"/>
</authentication>

<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false"
timeout="5"/>

</system.web>

<location path="Premium">
<system.web>
<authorization>
<allow roles="Premium"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

<location path="Premium.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

Apr 19 '07 #2
On 19 Apr, 16:12, "Peter Bradley" <pbrad...@uwic.ac.ukwrote:
Well, as I've said many times before on here, we use forms authentication
with attributes that ensure that users are both logged in and in the correct
role to carry out the action they are attempting. It works well for us, and
means we can get what we want with minimal coding. In fact all our code is
pretty much the standard code you will see if you look up Forms
Authentication on msdn.

If I wanted to keep a site secure, I wouldn't rely on cookies at the expense
of getting users to authenticate. I'd want a new authentication for every
new session.

Just my 2c. YMMV.

Peter
I suppose I should have said that I AM using forms authentification -
although you could have read as much from the snippet of web.config
which I gave.

The problem is that I'm only using some of it. The database already
exists. There's a member_group and member table in it. There are a
total of 8 roles for users and one of these roles is not stored in the
member table but in the member_group table. Some of these roles
depends upon combinations of column values from the tables.
Fortunately a member can only be in One member_group! - thank god for
small mercies.

As such there are major portions of the forms authentification
framework such as Membership which I can't use.

Anyhow, I found some helpful articles:

http://msdn2.microsoft.com/en-us/library/aa480476.aspx

http://msdn2.microsoft.com/en-us/library/ms978378.aspx

Anyhow there's a diagram in the first of thest URLs which indicates
that it all happens in the LoginUrl (Figure 1 - Forms Authentication
Control Flow) which I guess is what I needed to know.
Apr 19 '07 #3

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

Similar topics

5
by: PaulThomas | last post by:
Working with XP-Pro and VS.Net I have set my Start Page to "Home.aspx" but the application always starts the "Login" page - - - How can I change the start page to the Home.aspx??? On the login...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
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...
2
by: Joe Rigley | last post by:
Help Please! I've been tasked with converting a portion of the corporate web site that currently utilizes local user accounts and NTFS via Basic Authentication to access certain files on the...
6
by: \jason via DotNetMonster.com\ | last post by:
currently i am doing a personal website and keep on changing the aspect... finally the finall decision is to have a login page (requirement in asp.net, vb.net) and the login with security part of...
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
5
by: archana | last post by:
Hi all I am new to asp.net. I want to implement authentication in all pages. What i want to do is validate user from database table. So currently what i am doing is on login page validating...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?

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.