Class MySQLRoleProvider
Manages storage of role membership information for an ASP.NET application in a MySQL database.
Inheritance
Namespace: MySql.Web.Security
Assembly: MySql.Web.dll
Version: 9.1.0
Syntax
public sealed class MySQLRoleProvider : RoleProvider
Properties
ApplicationName
Gets or sets the name of the application to store and retrieve role information for.
Declaration
public override string ApplicationName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the application to store and retrieve role information for. |
Overrides
Examples
roleManager defaultProvider = "MySqlProvider"
enabled="true">
providers>
add
name = "MySqlProvider"
type="MySql.Web.Security.MySQLRoleProvider"
connectionStringName="LocalMySqlServices"
writeExceptionsToEventLog="false"
applicationName="MyApplication" />
/providers>
roleManager>
WriteExceptionsToEventLog
Gets or sets a value indicating whether exceptions should be written to the event log.
Declaration
public bool WriteExceptionsToEventLog { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
roleManager defaultProvider = "MySqlProvider"
enabled="true">
providers>
add
name = "MySqlProvider"
type="MySql.Web.Security.MySQLRoleProvider"
connectionStringName="LocalMySqlServices"
writeExceptionsToEventLog="false"
applicationName="MyApplication" />
/providers>
roleManager>
Methods
AddUsersToRoles(String[], String[])
Adds the users to the specified roles.
Declaration
public override void AddUsersToRoles(string[] usernames, string[] rolenames)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | usernames | The user names. |
System.String[] | rolenames | The role names. |
Overrides
CreateRole(String)
Creates the specified role.
Declaration
public override void CreateRole(string rolename)
Parameters
Type | Name | Description |
---|---|---|
System.String | rolename | The role name. |
Overrides
DeleteRole(String, Boolean)
Deletes the specified role.
Declaration
public override bool DeleteRole(string rolename, bool throwOnPopulatedRole)
Parameters
Type | Name | Description |
---|---|---|
System.String | rolename | The role name. |
System.Boolean | throwOnPopulatedRole | If set to |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
Exceptions
Type | Condition |
---|---|
System.Configuration.Provider.ProviderException | The specified role doesn't exist or |
FindUsersInRole(String, String)
Finds the users with the specified role.
Declaration
public override string[] FindUsersInRole(string rolename, string usernameToMatch)
Parameters
Type | Name | Description |
---|---|---|
System.String | rolename | The role name. |
System.String | usernameToMatch | The user name to match. |
Returns
Type | Description |
---|---|
System.String[] | A string array containing the names of all the users where the user name matches usernameToMatch and the user is a member of the specified role. |
Overrides
GetAllRoles()
Gets a list of all the roles for the configured applicationName.
Declaration
public override string[] GetAllRoles()
Returns
Type | Description |
---|---|
System.String[] | A string array containing the names of all the roles stored in the data source for the configured applicationName. |
Overrides
GetRolesForUser(String)
Gets a list of the roles that a specified user is in for the configured applicationName.
Declaration
public override string[] GetRolesForUser(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | The user to return a list of roles for. |
Returns
Type | Description |
---|---|
System.String[] | A string array containing the names of all the roles that the specified user is in for the configured applicationName. |
Overrides
GetUsersInRole(String)
Gets the users with the specified role.
Declaration
public override string[] GetUsersInRole(string rolename)
Parameters
Type | Name | Description |
---|---|---|
System.String | rolename | The role name. |
Returns
Type | Description |
---|---|
System.String[] | A string array containing the names of all the users who are members of the specified role. |
Overrides
Initialize(String, NameValueCollection)
Initializes the provider.
Declaration
public override void Initialize(string name, NameValueCollection config)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The friendly name of the provider. |
System.Collections.Specialized.NameValueCollection | config | A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The name of the provider is null. |
System.ArgumentException | The name of the provider has a length of zero. |
System.InvalidOperationException | An attempt is made to call System.Configuration.Provider.ProviderBase.Initialize(System.String, System.Collections.Specialized.NameValueCollection) on a provider after the provider has already been initialized. |
IsUserInRole(String, String)
Determines whether [is user in role] [the specified username].
Declaration
public override bool IsUserInRole(string username, string rolename)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | The username. |
System.String | rolename | The rolename. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
RemoveUsersFromRoles(String[], String[])
Removes the users from the specified roles.
Declaration
public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | usernames | The user names. |
System.String[] | rolenames | The role names. |
Overrides
RoleExists(String)
Determines whether the role exists.
Declaration
public override bool RoleExists(string rolename)
Parameters
Type | Name | Description |
---|---|---|
System.String | rolename | The rolename. |
Returns
Type | Description |
---|---|
System.Boolean | true if the role name already exists in the database; otherwise, false. |