473,408 Members | 1,907 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,408 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 1321
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
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:
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
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
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.