Technical Training
ASP.NET 2.0Table of Contents
ASP.NET Managing Membership and Roles
ASP.NET Managing Membership and Roles - Page 2
ASP.NET Managing Membership and Roles - Page 3
ASP.NET Managing Membership and Roles - Page 4ASP.NET Managing Membership and Roles Page - 2
ASP.NET Managing Membership and Roles
The Programming Interface
The Properties: A number of classes and interfaces have been defined in the membership class to encapsulate the logic for creating and managing users and for authenticating users on the basis of credentials input. The ApplicationName property gets and sets an optional string to identify the application. Defaults to the application’s metabase path. The EnablePasswordReset property returns true if the provider supports password reset. EnablePasswordRetrieval returns true if the provider supports password retrieval. Provider returns the instance of the currently configured provider. Providers returns the collection of all registered providers. RequiresQuestionAndAnswer returns true if the provider requires a password question/answer when retrieving or resetting the password. UserIsOnlineTimeWindow specifies the time window in minutes, during which the user is considered to be online.
The Methods:
A number of methods have also been made available in the Membership class which can be manipulated and customized by the developer. The CreateUser method creates a new user and fails if the user already exists. It returns a MembershipUser object that represents any information about the user. DeleteUser, deletes the user corresponding to the specified name. FindUsersByEmail returns a collection of membership users whose email address corresponds to the specified email. FindUsersByName as the name suggests finds the users corresponding to the name specified. GeneratePassword generates the random password of the specified path.
GetAllUsers returns a collection of all users. GetNumberOfUsersOnline returns the number of users currently online. GetUser retrieves the membership data of the user specified. GetUserNameByEmail obtains the user name that corresponds to the specified email if email is a unique identifier in the database. UpdateUser takes a MembershipUser object and updates information stored for the user. ValidateUser authenticates a user using supplied credentials. The UsersOnlineTimeWindow has a default value of 15 minutes. If the user has performed any activity in that 15 minutes he is considered online, else he is treated as offline by the applicaton.
Setting up the Membership
The membership API relies on a data store. The membership model supports a variety of storage media as long as the membership data provider exists. ASP.NET has two built in membership providers—one for the Access database and the other for the SQL server database. The membership database can be set up using the Web Application Administration Tool in Visual Studio 2005.
In the Login application we created navigate to the Website menu option and click on ASP.NET Configuration. Click on the security tab.

The wizard allows the developer create the membership database. This is Microsoft Access by default and users and roles can be added to it.
Ads
The Membership Provider
The membership provider model is extensible and extremely compact. Any database can be integrated with the Membership API by creating a custom provider for it. For instance if an Oracle database is to be linked with the Membership API the developer has to create a class that inherits from the MembershipProvider class, which in turn inherits from the Provider class. The code would read something like this:
public class OracleMembershipProvider:MembershipProvider
{
//implements all abstract members of the class and if needed defines //the custom functionality.
……
}
The Web.config file will also have to be tweaked to recognize this provider by specifying in the
< providers > section the name of the provider. Now the API is ready to instantiate the class and use it through the implemented interfaces.
ASP.NET 2.0
- Getting started with ASP.NET 2.0
- .NET Framework Fundamentals
- Microsoft.NET Framework Tools
- Application Development in .NET
- What's New in the .NET Framework 2.0 ?
- Introduction to Visual Studio.NET
- Installing Visual Studio.NET 2005
- Working with Visual Studio.NET Web Applications
- Whats New in ASP.NET 2.0
- Creating an ASP.NET Application
- ASP.NET Code Directory
- ASP.NET Page Object Model
- ASP.NET Server Controls
- ASP.NET Working With Master Pages
- ASP.NET Creating Content for Master Page
- ASP.NET Referencing Master Page Members
- ASP.NET Changing Master Pages Dynamically
- ASP.NET Creating Nested Master Pages
- ASP.NET Working with Web Parts
- ASP.NET Using Web Parts and Controls in Web Pages
- ASP.NET Web Pages and Layout
- ASP.NET - Adding Web Parts at Run Time
- ASP.NET Personalization: User Profiles and Themes
- ASP.NET Data Access features
- ASP.NET State Management
- ASP.NET Customizing the Session State Mechanism
- ASP.NET State Management And Caching
- ASP.NET Security
- Forms Authentication in ASP.NET
- ASP.NET Managing Membership and Roles
- ASP.NET Configuring Page-Level Caching
- ASP.NET Setting Application-Level Caching
- ASP.NET Data Source Object Model
- ASP.NET SqlDataSource Control
- ASP.NET Data Bound Controls
- ASP.NET GridView Control
- ASP.NET GridView Filtering
- ASP.NET Adding Sorting and Paging in GridView
- ASP.NET DataBound Controls - Details View
- ASP.NET Using a Grid to Display Detail Information
- ASP.NET Displaying Master-Detail Data on the Same Page
- Displaying Master-Detail Data on Separate Pages in ASP.NET
- ASP.NET Creating Web Wizards
- ASP.NET : Dynamic Image control
- ASP.NET Advanced Site Functionality







