Export (0) Print
Expand All

SimpleRoleProvider Class

Provides basic role-management functionality.

Namespace:  WebMatrix.WebData
Assembly:  WebMatrix.WebData (in WebMatrix.WebData.dll)

public class SimpleRoleProvider : RoleProvider

The SimpleRoleProvider type exposes the following members.

  NameDescription
Public methodSimpleRoleProvider()Initializes a new instance of the SimpleRoleProvider class.
Public methodSimpleRoleProvider(RoleProvider)Initializes a new instance of the SimpleRoleProvider class by using the specified role provider.
Top

  NameDescription
Public propertyApplicationNameGets or sets the name of the application to store and retrieve role information for. (Overrides RoleProvider.ApplicationName.)
Public propertyDescription (Inherited from ProviderBase.)
Public propertyName (Inherited from ProviderBase.)
Public propertyUserIdColumnGets the name of the database column that contains user IDs.
Public propertyUserNameColumnGets the name of the database column that contains user names.
Public propertyUserTableNameGets the name of the database table that contains user information.
Top

  NameDescription
Public methodAddUsersToRolesAdds the specified user names to the specified roles. (Overrides RoleProvider.AddUsersToRoles(String[], String[]).)
Public methodCreateRoleAdds a new role. (Overrides RoleProvider.CreateRole(String).)
Public methodDeleteRoleDeletes the specified role. (Overrides RoleProvider.DeleteRole(String, Boolean).)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodFindUsersInRoleReturns all of the specified users who are in the specified role. (Overrides RoleProvider.FindUsersInRole(String, String).)
Public methodGetAllRolesReturns a list of all roles. (Overrides RoleProvider.GetAllRoles().)
Public methodGetHashCode (Inherited from Object.)
Public methodGetRolesForUserReturns a list of the roles that a specified user is in. (Overrides RoleProvider.GetRolesForUser(String).)
Public methodGetType (Inherited from Object.)
Public methodGetUsersInRoleReturns the user names that are in the specified role. (Overrides RoleProvider.GetUsersInRole(String).)
Public methodInitialize (Inherited from ProviderBase.)
Public methodIsUserInRoleReturns a value that indicates whether the specified user is in the specified role. (Overrides RoleProvider.IsUserInRole(String, String).)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodRemoveUsersFromRolesRemoves the specified user names from the specified roles. (Overrides RoleProvider.RemoveUsersFromRoles(String[], String[]).)
Public methodRoleExistsReturns a value that indicates whether a specified role exists. (Overrides RoleProvider.RoleExists(String).)
Public methodToString (Inherited from Object.)
Top

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.

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