SimpleRoleProvider Class
Provides basic role-management functionality.
Inheritance Hierarchy
System.Object
System.Configuration.Provider.ProviderBase
System.Web.Security.RoleProvider
WebMatrix.WebData.SimpleRoleProvider
Namespace: WebMatrix.WebData
Assembly: WebMatrix.WebData (in WebMatrix.WebData.dll)
Syntax
'Declaration
Public Class SimpleRoleProvider _
Inherits RoleProvider
'Usage
Dim instance As SimpleRoleProvider
public class SimpleRoleProvider : RoleProvider
public ref class SimpleRoleProvider : public RoleProvider
type SimpleRoleProvider =
class
inherit RoleProvider
end
public class SimpleRoleProvider extends RoleProvider
The SimpleRoleProvider type exposes the following members.
Constructors
Name | Description | |
---|---|---|
SimpleRoleProvider() | Initializes a new instance of the SimpleRoleProvider class. | |
SimpleRoleProvider(RoleProvider) | Initializes a new instance of the SimpleRoleProvider class by using the specified role provider. |
Top
Properties
Name | Description | |
---|---|---|
ApplicationName | Gets or sets the name of the application to store and retrieve role information for. (Overrides RoleProvider.ApplicationName.) | |
CasingBehavior | Gets or sets the SimpleMembershipProviderCasingBehavior for this provider. | |
Description | (Inherited from ProviderBase.) | |
Name | (Inherited from ProviderBase.) | |
UserIdColumn | Gets the name of the database column that contains user IDs. | |
UserNameColumn | Gets the name of the database column that contains user names. | |
UserTableName | Gets the name of the database table that contains user information. |
Top
Methods
Name | Description | |
---|---|---|
AddUsersToRoles | Adds the specified user names to the specified roles. (Overrides RoleProvider.AddUsersToRoles(String[], String[]).) | |
CreateRole | Adds a new role. (Overrides RoleProvider.CreateRole(String).) | |
DeleteRole | Deletes the specified role. (Overrides RoleProvider.DeleteRole(String, Boolean).) | |
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
FindUsersInRole | Returns all of the specified users who are in the specified role. (Overrides RoleProvider.FindUsersInRole(String, String).) | |
GetAllRoles | Returns a list of all roles. (Overrides RoleProvider.GetAllRoles().) | |
GetHashCode | (Inherited from Object.) | |
GetRolesForUser | Returns a list of the roles that a specified user is in. (Overrides RoleProvider.GetRolesForUser(String).) | |
GetType | (Inherited from Object.) | |
GetUsersInRole | Returns the user names that are in the specified role. (Overrides RoleProvider.GetUsersInRole(String).) | |
Initialize | (Inherited from ProviderBase.) | |
IsUserInRole | Returns a value that indicates whether the specified user is in the specified role. (Overrides RoleProvider.IsUserInRole(String, String).) | |
MemberwiseClone | (Inherited from Object.) | |
RemoveUsersFromRoles | Removes the specified user names from the specified roles. (Overrides RoleProvider.RemoveUsersFromRoles(String[], String[]).) | |
RoleExists | Returns a value that indicates whether a specified role exists. (Overrides RoleProvider.RoleExists(String).) | |
ToString | (Inherited from Object.) |
Top
Remarks
Roles let you define groups (for example, managers, guests, administrators, members, and so on) that you can assign users to. You can then treat all users in a role the same for security, such as granting access to resources on your website. This is often more efficient than granting or denying access individually to each user.
There are no predefined roles, and you can create any roles (using any names) that are needed for your site. In effect, roles behave like tags that you can assign to users. You can then test for these tags (roles) when a user tries to access a page or other resource.
In an ASP.NET Web Pages site, you can manage and test roles by using the Roles property of a page. For example, to determine a user is in a particular role, you can call the Roles.IsUserInRole method.
By design, the SimpleRoleProvider class does not implement the full range of functionality that is possible in ASP.NET role providers, as defined in the RoleProvider base class that is used by all ASP.NET role providers. If your website requires the full role provider capabilities, you can skip initialization of the Web Pages role system (that is, do not call WebSecurity.InitializeDatabaseConnection()) and enable the standard membership and role providers. In that case, calls you make to the SimpleRoleProvider class are passed through to the standard provider (referred to as the previous provider in the SimpleRoleProvider class documentation). For more information, see Managing Authorization Using Roles.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.