What is Role provider in ASP.NET

During the development of ASP.NET application, the asp.net role management enables you the easy use of number of different providers. As you can implement your own provider or use the supplied profile providers which are included with the .NET Framework.

Reasons for creating a custom role provider:
  1. To store role information in a data source which doesn't supported by the role providers in the .NET Framework.
  2. To manage role information using a database schema different from the database schema used by the providers in the .NET Framework.
Implementing a role provider:

You need to create a class that inherits the RoleProvider abstract class from the System.Web.Security namespace. The RoleProvider abstract class then inherits the ProviderBase abstract class from the System.Configuration.Provider namespace. Next, you should retrieve the configuration information from the web.config file in the Initialize method.


At last, you have to implement GetRolesForUser method where you will get all the groups where the current user belongs to.


Thanx.