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

Authentication: Need to re-login for every directory

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.

Here is the settings:

I have a directory structure: //root/secure/admin/ where "secure" and
"admin" requires authorization.

in the "secure" directory, I have:
<configuration>
<system.web>
<customErrors mode="Off"/>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>

in the "admin" directory, I have:
<configuration>
<system.web>
<customErrors mode="Off"/>
<authorization>
<allow roles="Admin"/>
<deny users="?" />
</authorization>
</system.web>
</configuration>

and in the Application_AuthenticateRequest event, I have:
if (Request.IsAuthenticated)
{
string[] roles = rtkShirts.Component.adminBO.getPrivilege(HttpConte xt.Current.User.Identity.Name);
if (roles != null)
{
HttpContext.Current.User = new
System.Security.Principal.GenericPrincipal(User.Id entity, roles);
}
}

I test the page as follows:
1. go to a page under "secure" directory.
2. bounced to login.aspx (under root)
3. logged in, return to the page I suppose to go (and I check in the
Application_AuthenticateRequest event that I have "Admin" as one of
the entry inside [string[] roles]).
4. I click on a link to a page under "secure/admin"
5. I got bounced back to login.aspx (shouldn't happen)
6. I re-login and now I reach the page I want to go.
Please help. I'm pretty new to the field so please pardon me if some
of the wording I used sounds funny.

Thanks for concern,
Homa Wong
Nov 17 '05 #1
1 1605
Hi,
nevermind. I found out what's the problem. I'm using VS.NET to
develop the page. And I set the page to start at the page within the
secure folder. For some reason, the very first request made by VS.NET
is different than the others. ASP.NET consider it as a different user,
so that's why I ask me to login twice. After I logged in the second
time, everything works fine; same as when I run the site directly by
typing the URL in browser.

Thanks and Happy programming.

Homa Wong

ho******@yahoo.com (Homa) wrote in message news:<a9**************************@posting.google. com>...
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.

Here is the settings:

I have a directory structure: //root/secure/admin/ where "secure" and
"admin" requires authorization.

in the "secure" directory, I have:
<configuration>
<system.web>
<customErrors mode="Off"/>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>

in the "admin" directory, I have:
<configuration>
<system.web>
<customErrors mode="Off"/>
<authorization>
<allow roles="Admin"/>
<deny users="?" />
</authorization>
</system.web>
</configuration>

and in the Application_AuthenticateRequest event, I have:
if (Request.IsAuthenticated)
{
string[] roles = rtkShirts.Component.adminBO.getPrivilege(HttpConte xt.Current.User.Identity.Name);
if (roles != null)
{
HttpContext.Current.User = new
System.Security.Principal.GenericPrincipal(User.Id entity, roles);
}
}

I test the page as follows:
1. go to a page under "secure" directory.
2. bounced to login.aspx (under root)
3. logged in, return to the page I suppose to go (and I check in the
Application_AuthenticateRequest event that I have "Admin" as one of
the entry inside [string[] roles]).
4. I click on a link to a page under "secure/admin"
5. I got bounced back to login.aspx (shouldn't happen)
6. I re-login and now I reach the page I want to go.
Please help. I'm pretty new to the field so please pardon me if some
of the wording I used sounds funny.

Thanks for concern,
Homa Wong

Nov 17 '05 #2

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

Similar topics

6
by: Pete Mahoney | last post by:
I am trying to 'POST' values from a form in a ASP file that has anonymous access permissions. I can retrieve the form values when I redirect to this page from another page which has also has...
5
by: DSISupport | last post by:
Hi, I'm planing to use the enterprise library in a new web project, and I was looking at the Security application block which came by defaul with one provider called database authentication...
1
by: Konrad | last post by:
Hi All users should authenticate to reach some page. How to avoid this for some users. Thanks Konrad
0
by: SPuR | last post by:
Hi, I'm developing an asp.net page and I need to force windows authentication in a https server. When I request the page for first time, it request me for authentication, but I need that each time...
3
by: Stephanie Stowe | last post by:
I am new to ASP.NET having come from ASP classic background. I need to understand authentication. I have a server running IIS which contains an ASP.NET app. On IIS the app has both anonymous and...
4
by: tripwater | last post by:
Hello, I am currently trying to learn VS, using C#. I have a book called Beginning C# Databases. I am using sqlserver and the first half of the book deals with windows apps. So it uses the windows...
5
by: Jon Skeet [C# MVP] | last post by:
I've run against a problem which I'm *sure* must be easy to solve - but I'm blowed if I can find the answer :( I have a web service which I want to require authentication. I need to authenticate...
6
by: Eng.Rana | last post by:
Hello All, i was wondering what is the main difference between the windows authentication and mixed mode authentication?? according to security recommendations, we should enable windows...
2
by: Frank Swarbrick | last post by:
I am trying to understand "client authentication" works. My environment is DB2/UDB LUW 8.2 on zSeries SLES9 as the database server and DB2 for VSE 7.4 as the client. We currently have DB2/LUW set...
0
by: =?Utf-8?B?S29uc3RhbnRpbg==?= | last post by:
I am currently working on the application that need to simulate basic authentication programmatically using user's credentials that are known. Basically, the need is for a single sign on with a...
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
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...

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.