Implementing your own Membership Provider


ASP.NET has already provided membership providers that are included with the .NET Framework. You can use them directly for any web sites without spending your more design. However, you must feel the supplied membership providers are not convenient for your projects. Microsoft MSDN site also gave the reasons why you need to implement your own Membership provider:

There are two common reasons for creating a custom membership provider.

  • You need to store membership information in a data source that is not supported by the membership providers included with the .NET Framework, such as a FoxPro database, an Oracle database, or other data sources.
  • You need to manage membership information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. A common example of this would be membership data that already exists in a SQL Server database for a company or Web site._

How to implement a Membership Provider ? What are the required stuff ?

(The following content is brief note from Microsoft MSDN)

Required Classes:

Create a class that inherits the MembershipProvider abstract class, you must implement the required members of the ProviderBase class.

The following tables list the required properties and methods that you must implement from the ProviderBase and MembershipProvider abstract classes:

Required ProviderBase Members:

Initialize method

Required MembershipProvider Members:

EnablePasswordReset property
EnablePasswordRetrieval property
RequiresQuestionAndAnswer property
RequiresUniqueEmail property
PasswordFormat property
MaxInvalidPasswordAttempts property
PasswordAttemptWindow property
ApplicationName property
MembershipProvider.CreateUser method
UpdateUser method
DeleteUser method
ValidateUser method
GetUser method
GetUser method
GetAllUsers method
GetNumberOfUsersOnline method
ResetPassword method
GetPassword method
GetUserNameByEmail method
ChangePassword method
ChangePasswordQuestionAndAnswer method
FindUsersByName method
FindUsersByEmail method
UnlockUser method

For more detail information, please read Microsoft MSDN page.