472,784 Members | 969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

Forms auth for directory

Hi guys

Ok, I have a website which has an "Artists Only" section, for which you have
to login for. This section is contained within its own directory on the
server "/aonly".

I want to make people login before they can access this directory, with a
User control on each page for logging in. I'd like to use Forms auth and sql
server (i know how to check that against the entered details).

I also want a login.aspx page so that if their session expires, it's easy to
log back in.

Question is.. how do I create the forms auth and make it protect the
"/aonly" directory, and can I make the user control authenticate the user,
and then forward to the protected directory?

HOpe that makes sense!

Cheers
Dan
Nov 19 '05 #1
4 1293
You should enable forms authentication in your root web.config (root of you
application, that is). For the subdirectory, you should then set the authorization
to not allow anonymous users. I presume the rest of the site is accessible
to anonymous users?

Here are the docs for configuring forms authentication:

http://msdn.microsoft.com/library/de...gngrfforms.asp

And here's how you'd set the authorization:

http://msdn.microsoft.com/library/de...asp?frame=true

Now since you're looking to control authorization on a subdirectory, the
authorization could go into an independant web.config in the child directory
you want to contol access to.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi guys

Ok, I have a website which has an "Artists Only" section, for which
you have to login for. This section is contained within its own
directory on the server "/aonly".

I want to make people login before they can access this directory,
with a User control on each page for logging in. I'd like to use Forms
auth and sql server (i know how to check that against the entered
details).

I also want a login.aspx page so that if their session expires, it's
easy to log back in.

Question is.. how do I create the forms auth and make it protect the
"/aonly" directory, and can I make the user control authenticate the
user, and then forward to the protected directory?

HOpe that makes sense!

Cheers

Dan


Nov 19 '05 #2
Thanks Brock,

That seems to have got all the security stuff setup. I'm assuming I put the
code to authenticate against SQL in a function called by the clicking of my
signup button, is that right?

In which case, when I've authenticated a user, what do I need to set in
order for Forms authentication to let them in?

Cheers
Dan
"Brock Allen" wrote:
You should enable forms authentication in your root web.config (root of you
application, that is). For the subdirectory, you should then set the authorization
to not allow anonymous users. I presume the rest of the site is accessible
to anonymous users?

Here are the docs for configuring forms authentication:

http://msdn.microsoft.com/library/de...gngrfforms.asp

And here's how you'd set the authorization:

http://msdn.microsoft.com/library/de...asp?frame=true

Now since you're looking to control authorization on a subdirectory, the
authorization could go into an independant web.config in the child directory
you want to contol access to.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi guys

Ok, I have a website which has an "Artists Only" section, for which
you have to login for. This section is contained within its own
directory on the server "/aonly".

I want to make people login before they can access this directory,
with a User control on each page for logging in. I'd like to use Forms
auth and sql server (i know how to check that against the entered
details).

I also want a login.aspx page so that if their session expires, it's
easy to log back in.

Question is.. how do I create the forms auth and make it protect the
"/aonly" directory, and can I make the user control authenticate the
user, and then forward to the protected directory?

HOpe that makes sense!

Cheers

Dan


Nov 19 '05 #3
k
You want to do something like this

public void Login_Click(Object sender, EventArgs E)
{

_UserName = UserName.Value;
_Password = UserPass.Value;

if (CheckUserAndPassword (_ServerName, _DatabaseName,_UserName
,_Password))
{
System.Web.Security.FormsAuthentication.RedirectFr omLoginPage(UserName.Value,false);
}
else
{
Msg.Text = "Invalid Credentials: Please try again";
}
}
which puts them back to the originally requested URL.

Kirsty

Nov 19 '05 #4
> That seems to have got all the security stuff setup. I'm assuming I
put the code to authenticate against SQL in a function called by the
clicking of my signup button, is that right?
Right - you'll have to write the code to do the actual authentication against
your database of usernames/passwords.
In which case, when I've authenticated a user, what do I need to set
in order for Forms authentication to let them in?


So once you know the user has provided valid credntials, you use FormsAuthentication.RedirectFromLoginPage("TheirUs ername",
false) or FormsAuthentication.SetAuthCookie to tell ASP.NET that they're
logged in.

-Brock
DevelopMentor
http://staff.develop.com/ballen


Nov 19 '05 #5

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

Similar topics

1
by: tascien | last post by:
I an application that i want to set up for two clients. http://localhost/client1 <- virtual directory. http://localhost/client2 <- virtual directory. Now, i don't want these application to...
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...
1
by: tascien | last post by:
I an application that i want to set up for two clients. http://localhost/client1 <- virtual directory. http://localhost/client2 <- virtual directory. Now, i don't want these application to...
3
by: Smokey Grindle | last post by:
I am using forms authentication with a custom user database... I was wondering, when logging in using forms auth, does the HttpContext.Current.User return the forms logged in user or the AD user...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.