Using Forms Authentication with Membership Providers in ASP.NET 2.0
page 1 of 6
Published: 09 Jun 2008
Abstract
This article examines the usage of Forms Authentication with Membership Providers using ASP.NET 2.0 in a series of parts. After providing a detailed overview of the concepts, Sudeep demonstrates setting up ActiveDirectoryMembershipProvider, ActiveDirectoryMembershipProvider with Active Directory Application Mode, and the usage of SqlMembershipProvider and SQL Role Provider in a step-by-step manner with the help of sample code listings. In addition to these, he also enlists the use of AuthorizationManager with Active Directory Membership Provider.
by Sudeep G
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 53164/ 64

Introduction

It has been sometime since I wrote an article. I was away learning more on IIS 7. In the meantime, I was also spending some time writing samples in C# for ASP.NET. I like coding with C#. I think the language has a lot of power and grace. Today, I am going to write about step-by-step procedures to setup Forms Authentication using ASP.NET 2.0 Membership Providers. In my opinion, the providers are one of the greatest features of ASP.NET 2.0.

As you may know, forms authentication is especially useful when you want to authenticate a user from the internet. In the previous versions all of the coding against the authentication store needed to be done by the developer himself. Microsoft has made this easier by providing membership providers that allow you to authenticate against commonly used authentication stores without any code. Keep in mind that these providers work for most cases, but you could still extend these classes and write your own provider.

The membership providers provide excellent abstraction for the web application with the underlying authentication store. The providers that are currently available are:

1. SqlMembershipProvider

2. ActiveDirectoryMembershipProvider

SqlMembershipProvider works against the Microsoft SQL Server databases. ActiveDirectoryMembershipProvider works against Microsoft Windows Active Directory and Active Directory Application Mode (ADAM). In this posting I want to show you how to accomplish the following:

1. Setting up ActiveDirectoryMembershipProvider.

2. Using AuthorizationManager (Azman) with these providers.

3. Touch up on Active Directory Application Mode.

4. Setting up and using SqlMembershipProvider.

To best test your scenarios, it will be really good to have a virtual setup of your own with a domain controller, a web server and a client machine. I setup 4 virtual machines to test these scenarios: A domain controller running Windows Server 2003 SP2, a web server running Windows Server 2003 SP2, Windows XP Pro SP2 and a Windows Server 2003 SP2 hosting SQL Server 2005 instance. I will mark out the places where you will need to make changes for your environment.

Ingredients: We need some basic ingredients to start that we can re-use. Also, I have tried to use as much default settings and minimal code possible so that much of the work is done by ASP.NET. I also explained the attributes that you can optionally configure. You can download these from the download link to start with.

·         Default.aspx

·         ManagementHome.aspx

·         Login.aspx

·         Web.config

 

Besides this, we need to configure the membership providers correctly to make this work. Configuring membership providers is easy. You need a Membership provider, a role provider and a SQL Connection string that is mapped to these providers. Besides these, there are a few attributes that are common to almost all membership providers.

1.    Name

2.    ApplicationName

3.    Type


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-15 5:39:15 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search