C# Class MySql.Web.Security.MySQLMembershipProvider

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

This class is used by the Membership and MembershipUser classes to provide membership services for ASP.NET applications using a MySQL database.

Inheritance: System.Web.Security.MembershipProvider
Mostrar archivo Open project: elevate/mysqlconnector-.net Class Usage Examples

Public Methods

Method Description
ChangePassword ( string username, string oldPassword, string newPassword ) : bool

Changes the password.

ChangePasswordQuestionAndAnswer ( string username, string password, string newPwdQuestion, string newPwdAnswer ) : bool

Changes the password question and answer.

CreateUser ( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, MembershipCreateStatus &status ) : System.Web.Security.MembershipUser

Adds a new membership user to the data source.

DeleteUser ( string username, bool deleteAllRelatedData ) : bool

Removes a user from the membership data source.

FindUsersByEmail ( string emailToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection

Gets a collection of membership users where the e-mail address contains the specified e-mail address to match.

FindUsersByName ( string usernameToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection

Gets a collection of membership users where the user name contains the specified user name to match.

GetAllUsers ( int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection

Gets a collection of all the users in the data source in pages of data.

GetNumberOfUsersOnline ( ) : int

Gets the number of users currently accessing the application.

GetPassword ( string username, string answer ) : string

Gets the password for the specified user name from the data source.

GetUser ( object providerUserKey, bool userIsOnline ) : System.Web.Security.MembershipUser

Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.

GetUser ( string username, bool userIsOnline ) : System.Web.Security.MembershipUser

Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user.

GetUserNameByEmail ( string email ) : string

Gets the user name associated with the specified e-mail address.

Initialize ( string name, NameValueCollection config ) : void

Initializes the MySQL membership provider with the property values specified in the ASP.NET application's configuration file. This method is not intended to be used directly from your code.

ResetPassword ( string username, string answer ) : string

Resets a user's password to a new, automatically generated password.

UnlockUser ( string username ) : bool

Unlocks the user.

UpdateUser ( System.Web.Security.MembershipUser user ) : void

Updates information about a user in the data source.

ValidateUser ( string username, string password ) : bool

Verifies that the specified user name and password exist in the data source.

Private Methods

Method Description
CheckPassword ( string password, string dbpassword, string passwordKey, MembershipPasswordFormat format ) : bool
EncodePassword ( string password, string passwordKey, MembershipPasswordFormat format ) : string
GetConfigValue ( string configValue, string defaultValue ) : string
GetPasswordInfo ( MySqlConnection connection, int userId, string &passwordKey, MembershipPasswordFormat &passwordFormat ) : void
GetPasswordKey ( ) : string
GetUserFromReader ( MySqlDataReader reader ) : System.Web.Security.MembershipUser
GetUserId ( MySqlConnection connection, string username ) : int
GetUsers ( string username, string email, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
HashPasswordBytes ( byte bytes ) : string

this method is only necessary because early versions of Mono did not support the HashAlgorithmType property

UnEncodePassword ( string encodedPassword, MembershipPasswordFormat format ) : string
UpdateFailureCount ( int userId, string failureType, MySqlConnection connection ) : void
ValidatePassword ( string password, string argumentName, bool throwExceptions ) : bool
ValidateQA ( string question, string answer ) : void
WriteToEventLog ( Exception e, string action ) : void

Method Details

ChangePassword() public method

Changes the password.
public ChangePassword ( string username, string oldPassword, string newPassword ) : bool
username string The username.
oldPassword string The old password.
newPassword string The new password.
return bool

ChangePasswordQuestionAndAnswer() public method

Changes the password question and answer.
public ChangePasswordQuestionAndAnswer ( string username, string password, string newPwdQuestion, string newPwdAnswer ) : bool
username string The username.
password string The password.
newPwdQuestion string The new password question.
newPwdAnswer string The new password answer.
return bool

CreateUser() public method

Adds a new membership user to the data source.
public CreateUser ( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, MembershipCreateStatus &status ) : System.Web.Security.MembershipUser
username string The user name for the new user.
password string The password for the new user.
email string The e-mail address for the new user.
passwordQuestion string The password question for the new user.
passwordAnswer string The password answer for the new user
isApproved bool Whether or not the new user is approved to be validated.
providerUserKey object The unique identifier from the membership data source for the user.
status MembershipCreateStatus A enumeration value indicating whether the user was created successfully.
return System.Web.Security.MembershipUser

DeleteUser() public method

Removes a user from the membership data source.
public DeleteUser ( string username, bool deleteAllRelatedData ) : bool
username string The name of the user to delete.
deleteAllRelatedData bool true to delete data related to the user from the database; false to leave data related to the user in the database.
return bool

FindUsersByEmail() public method

Gets a collection of membership users where the e-mail address contains the specified e-mail address to match.
public FindUsersByEmail ( string emailToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
emailToMatch string The e-mail address to search for.
pageIndex int The index of the page of results to return. is zero-based.
pageSize int The size of the page of results to return.
totalRecords int The total number of matched users.
return System.Web.Security.MembershipUserCollection

FindUsersByName() public method

Gets a collection of membership users where the user name contains the specified user name to match.
public FindUsersByName ( string usernameToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
usernameToMatch string The user name to search for.
pageIndex int The index of the page of results to return. is zero-based.
pageSize int The size of the page of results to return.
totalRecords int The total number of matched users.
return System.Web.Security.MembershipUserCollection

GetAllUsers() public method

Gets a collection of all the users in the data source in pages of data.
public GetAllUsers ( int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
pageIndex int The index of the page of results to return. is zero-based.
pageSize int The size of the page of results to return.
totalRecords int The total number of matched users.
return System.Web.Security.MembershipUserCollection

GetNumberOfUsersOnline() public method

Gets the number of users currently accessing the application.
public GetNumberOfUsersOnline ( ) : int
return int

GetPassword() public method

Gets the password for the specified user name from the data source.
public GetPassword ( string username, string answer ) : string
username string The user to retrieve the password for.
answer string The password answer for the user.
return string

GetUser() public method

Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.
public GetUser ( object providerUserKey, bool userIsOnline ) : System.Web.Security.MembershipUser
providerUserKey object The unique identifier for the membership user to get information for.
userIsOnline bool true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.
return System.Web.Security.MembershipUser

GetUser() public method

Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user.
public GetUser ( string username, bool userIsOnline ) : System.Web.Security.MembershipUser
username string The name of the user to get information for.
userIsOnline bool true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.
return System.Web.Security.MembershipUser

GetUserNameByEmail() public method

Gets the user name associated with the specified e-mail address.
public GetUserNameByEmail ( string email ) : string
email string The e-mail address to search for.
return string

Initialize() public method

Initializes the MySQL membership provider with the property values specified in the ASP.NET application's configuration file. This method is not intended to be used directly from your code.
config is a null reference. An attempt is made to call on a provider after the provider has already been initialized.
public Initialize ( string name, NameValueCollection config ) : void
name string The name of the instance to initialize.
config System.Collections.Specialized.NameValueCollection A collection of the name/value pairs representing the /// provider-specific attributes specified in the configuration for this provider.
return void

ResetPassword() public method

Resets a user's password to a new, automatically generated password.
public ResetPassword ( string username, string answer ) : string
username string The user to reset the password for.
answer string The password answer for the specified user.
return string

UnlockUser() public method

Unlocks the user.
public UnlockUser ( string username ) : bool
username string The username.
return bool

UpdateUser() public method

Updates information about a user in the data source.
public UpdateUser ( System.Web.Security.MembershipUser user ) : void
user System.Web.Security.MembershipUser A object /// that represents the user to update and the updated information for the user.
return void

ValidateUser() public method

Verifies that the specified user name and password exist in the data source.
public ValidateUser ( string username, string password ) : bool
username string The name of the user to validate.
password string The password for the specified user.
return bool