Export (0) Print
Expand All

RoleProvider Class

Defines the contract that ASP.NET implements to provide role-management services using custom role providers.

Namespace:  System.Web.Security
Assembly:  System.Web.ApplicationServices (in System.Web.ApplicationServices.dll)

public abstract class RoleProvider : ProviderBase

The RoleProvider type exposes the following members.

  NameDescription
Protected methodRoleProviderInitializes a new instance of the RoleProvider class.
Top

  NameDescription
Public propertyApplicationNameGets or sets the name of the application to store and retrieve role information for.
Public propertyDescriptionGets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs). (Inherited from ProviderBase.)
Public propertyNameGets the friendly name used to refer to the provider during configuration. (Inherited from ProviderBase.)
Top

  NameDescription
Public methodAddUsersToRolesAdds the specified user names to the specified roles for the configured applicationName.
Public methodCreateRoleAdds a new role to the data source for the configured applicationName.
Public methodDeleteRoleRemoves a role from the data source for the configured applicationName.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindUsersInRoleGets an array of user names in a role where the user name contains the specified user name to match.
Public methodGetAllRolesGets a list of all the roles for the configured applicationName.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetRolesForUserGets a list of the roles that a specified user is in for the configured applicationName.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUsersInRoleGets a list of users in the specified role for the configured applicationName.
Public methodInitializeInitializes the provider. (Inherited from ProviderBase.)
Public methodIsUserInRoleGets a value indicating whether the specified user is in the specified role for the configured applicationName.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveUsersFromRolesRemoves the specified user names from the specified roles for the configured applicationName.
Public methodRoleExistsGets a value indicating whether the specified role name already exists in the role data source for the configured applicationName.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

ASP.NET role management is designed to enable you to easily use a number of different role providers for your ASP.NET applications. You can use the supplied role providers that are included with the .NET Framework, or you can implement your own provider.

When implementing a custom role provider, you are required to inherit the RoleProvider abstract class.

There are two primary reasons for creating a custom role provider.

  • You need to store role information in a data source that is not supported by the role providers included with the .NET Framework, such as a FoxPro database, an Oracle database, or other data sources.

  • You need to manage role 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 role data that already exists in a SQL Server database for a company or Web site.

TopicLocation
How to: Sample Role-Provider ImplementationBuilding ASP .NET Web Applications
Implementing a Role ProviderBuilding ASP .NET Web Applications
How to: Sample Role-Provider ImplementationBuilding ASP .NET Web Applications
Implementing a Role ProviderBuilding ASP .NET Web Applications

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft