Search Results for

    Show / Hide Table of Contents

    Class MySQLRoleProvider

    Manages storage of role membership information for an ASP.NET application in a MySQL database.

    Inheritance
    System.Object
    System.Configuration.Provider.ProviderBase
    System.Web.Security.RoleProvider
    MySQLRoleProvider
    Namespace: MySql.Web.Security
    Assembly: MySql.Web.dll
    Version: 9.3.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
    System.Web.Security.RoleProvider.ApplicationName
    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

    true if exceptions should be written to the event log; otherwise, false.

    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
    System.Web.Security.RoleProvider.AddUsersToRoles(System.String[], System.String[])

    CreateRole(String)

    Creates the specified role.

    Declaration
    public override void CreateRole(string rolename)
    Parameters
    Type Name Description
    System.String rolename

    The role name.

    Overrides
    System.Web.Security.RoleProvider.CreateRole(System.String)

    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 true a System.Configuration.Provider.ProviderException will be raised if there are users with the specified role.

    Returns
    Type Description
    System.Boolean

    true if the role was successfully deleted; otherwise, false.

    Overrides
    System.Web.Security.RoleProvider.DeleteRole(System.String, System.Boolean)
    Exceptions
    Type Condition
    System.Configuration.Provider.ProviderException

    The specified role doesn't exist or throwOnPopulatedRole is set to true and there are users with the specified role.

    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
    System.Web.Security.RoleProvider.FindUsersInRole(System.String, System.String)

    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
    System.Web.Security.RoleProvider.GetAllRoles()

    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
    System.Web.Security.RoleProvider.GetRolesForUser(System.String)

    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
    System.Web.Security.RoleProvider.GetUsersInRole(System.String)

    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
    System.Configuration.Provider.ProviderBase.Initialize(System.String, System.Collections.Specialized.NameValueCollection)
    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

    true if [is user in role] [the specified username]; otherwise, false.

    Overrides
    System.Web.Security.RoleProvider.IsUserInRole(System.String, System.String)

    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
    System.Web.Security.RoleProvider.RemoveUsersFromRoles(System.String[], System.String[])

    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.

    Overrides
    System.Web.Security.RoleProvider.RoleExists(System.String)
    In This Article
    Back to top Copyright © 2021, 2025, Oracle and/or its affiliates.
    OSZAR »