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

Forms Authentication for single directory

Hi, I've taken over a website, which has an admin section that is
currently open. I added Forms Authentication to the admin directory
with the using the location section in web.config:

<location path="admin">
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms name=".COOKIEDEMO" loginUrl="login.aspx"
protection="All" timeout="60" path="/">
<credentials passwordFormat="Clear">
<user name="login1" password="password1"/>
<user name="login2" password="password2"/>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>

To get this to work for a single directory, I had to use IIS and turn
the directory into a web app. This makes the authentication work
correctly, however it breaks all the existing code in admin.

My question is this: Is there a way to use Forms Authentication for a
single directory of a web site, WITHOUT running the directory as a
separate web app? I can't seem to find any documentation on
protecting a single directory.

Thanks in advance. - Sean
Nov 14 '08 #1
1 2554
Hi Sean,

I think I did something a while ago which sounds like what you're trying to
do and got it to work without turning the admin directory into it's own web
application. I forget the exact steps but in the web.config I have:
....
<location path="Admin">
<system.web>
<authorization>
<allow users="user1"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
....
<authentication mode="Forms">
<forms loginUrl="RoleLogin.aspx" protection="None" timeout="30" path="/">
<credentials passwordFormat="Clear">
<user name = "user1" password = "password1" /?
</credentials>
</forms>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
.....
At the time I was doing this website, I ran across across an article which I
think did a nice job of walking through the <location/element. I think this
is the article:
http://www.theserverside.net/tt/arti...Authentication (like I said it was a while ago).

Eventually, I changed things so that I used the SqlMembership provider and
roles to manage access to assets on the website. A nice improvement.

For things which have to do with ASP.NET Security, Membership, and Roles
check out the this book - Professional ASP.NET 2.0 Security, Membership, and
Role Management by Stefan Schackow.

--
brians
http://www.limbertech.com
"Sean" wrote:
Hi, I've taken over a website, which has an admin section that is
currently open. I added Forms Authentication to the admin directory
with the using the location section in web.config:

<location path="admin">
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms name=".COOKIEDEMO" loginUrl="login.aspx"
protection="All" timeout="60" path="/">
<credentials passwordFormat="Clear">
<user name="login1" password="password1"/>
<user name="login2" password="password2"/>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>

To get this to work for a single directory, I had to use IIS and turn
the directory into a web app. This makes the authentication work
correctly, however it breaks all the existing code in admin.

My question is this: Is there a way to use Forms Authentication for a
single directory of a web site, WITHOUT running the directory as a
separate web app? I can't seem to find any documentation on
protecting a single directory.

Thanks in advance. - Sean
Nov 14 '08 #2

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

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
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: Eric | last post by:
I am trying to build an app where the stuff in the root directory is open to all, but anything under the Restricted directory requires you to login and I want to use Forms to do it. I'm having...
12
by: Brett Robichaud | last post by:
Is anyone familiar with this error? I have this running just fine on my local machine but when I pushed it out to our development server I get this error. I have no idea what it is saying. Any...
2
by: Thomas Scheiderich | last post by:
I am trying to set up forms authentication in my IIS pages. I have a folder inside of my root folder I am trying to protect and I am getting an error when a page in the folder is accessed. The...
1
by: Sumaira Ahmad | last post by:
Hi, Please help me with this.. I am trying to use Forms Authentication in a sample project. I basically want to have two folders in my application , one in which I store pages that can be...
7
by: Justin | last post by:
I am trying to password protect a subdirectory using forms authentication. I am using the "Location" tag to specify the directory to be protected. The login.aspx page is in the root directory of...
3
by: David GB | last post by:
I'm trying to set u forms mode authentiaction on a sub-directory. The web.config for the overall site is set to <authentication mode="None" /> In the sub-directory I have a very simple...
4
by: sunniyeow | last post by:
Hi, My question is regarding password protecting 2 different folders inside a single virtual directory using forms authentication method. Easier if I illustrate things out... - <authentication...
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
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:
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
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,...
0
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...

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.