Share via


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
Public method SimpleRoleProvider() Initializes a new instance of the SimpleRoleProvider class.
Public method SimpleRoleProvider(RoleProvider) Initializes a new instance of the SimpleRoleProvider class by using the specified role provider.

Top

Properties

  Name Description
Public property ApplicationName Gets or sets the name of the application to store and retrieve role information for. (Overrides RoleProvider.ApplicationName.)
Public property CasingBehavior Gets or sets the SimpleMembershipProviderCasingBehavior for this provider.
Public property Description (Inherited from ProviderBase.)
Public property Name (Inherited from ProviderBase.)
Public property UserIdColumn Gets the name of the database column that contains user IDs.
Public property UserNameColumn Gets the name of the database column that contains user names.
Public property UserTableName Gets the name of the database table that contains user information.

Top

Methods

  Name Description
Public method AddUsersToRoles Adds the specified user names to the specified roles. (Overrides RoleProvider.AddUsersToRoles(String[], String[]).)
Public method CreateRole Adds a new role. (Overrides RoleProvider.CreateRole(String).)
Public method DeleteRole Deletes the specified role. (Overrides RoleProvider.DeleteRole(String, Boolean).)
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method FindUsersInRole Returns all of the specified users who are in the specified role. (Overrides RoleProvider.FindUsersInRole(String, String).)
Public method GetAllRoles Returns a list of all roles. (Overrides RoleProvider.GetAllRoles().)
Public method GetHashCode (Inherited from Object.)
Public method GetRolesForUser Returns a list of the roles that a specified user is in. (Overrides RoleProvider.GetRolesForUser(String).)
Public method GetType (Inherited from Object.)
Public method GetUsersInRole Returns the user names that are in the specified role. (Overrides RoleProvider.GetUsersInRole(String).)
Public method Initialize (Inherited from ProviderBase.)
Public method IsUserInRole Returns a value that indicates whether the specified user is in the specified role. (Overrides RoleProvider.IsUserInRole(String, String).)
Protected method MemberwiseClone (Inherited from Object.)
Public method RemoveUsersFromRoles Removes the specified user names from the specified roles. (Overrides RoleProvider.RemoveUsersFromRoles(String[], String[]).)
Public method RoleExists Returns a value that indicates whether a specified role exists. (Overrides RoleProvider.RoleExists(String).)
Public method 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.

See Also

Reference

WebMatrix.WebData Namespace