C# Class Worki.Memberships.WorkiMembershipProvider

Inheritance: System.Web.Security.MembershipProvider
显示文件 Open project: tah91/eworkyWebSite

Private Properties

Property Type Description
CheckPassword bool
EncodePassword string
GeneratePassword string
GenerateSalt string
GetConfigValue string
GetUserFromMember System.Web.Security.MembershipUser
HexToByte byte[]
ResetAuthenticationFailures void
UnEncodePassword string

Public Methods

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

Change the current password for a new one. Note: Both are required.

ChangePasswordQuestionAndAnswer ( string username, string password, string newPasswordQuestion, string newPasswordAnswer ) : bool

Change the password retreival/reset question and answer pair

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

Creates a new user with a given set of default values

DeleteUser ( string username, bool deleteAllRelatedData ) : bool

Permanently deletes a user from the database

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

Finds a list of users with a matching email address

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

Gets a list of users with a matching username

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

Gets all the users in the database

GetNumberOfUsersOnline ( ) : int

Gets the total number of users that are currently online.

GetPassword ( string username, string answer ) : string

Gets the current password of a user (provided it isn't hashed)

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

Gets a MembershipUser object with a given key

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

Gets a MembershipUser object with a given username

GetUserNameByEmail ( string email ) : string

Gets the username by a given matching email address

Initialize ( string name, System config ) : void
ResetPassword ( string username, string answer ) : string

Resets the passwords with a generated value

UnlockUser ( string userName ) : bool

Unlocks a user (after too many login attempts perhaps)

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

Updates an existing user with new settings

ValidateUser ( string username, string password ) : bool

Authenticates a user with the given username and password

Private Methods

Method Description
CheckPassword ( string password, string dbpassword, string dbsalt ) : bool

Compares a given password with one stored in the database and an optional salt

EncodePassword ( string password ) : string

Encodes a given password using the default MembershipPasswordFormat setting

GeneratePassword ( int passLength ) : string

Generates a random password of given length (MinRequiredPasswordLength)

GenerateSalt ( ) : string

Salt generation helper (this is essentially the same as the one in SqlMembershipProviders

GetConfigValue ( string configValue, string defaultValue ) : string

Used in the initializtion, key in web.config or the default setting if null.

GetUserFromMember ( Member m ) : System.Web.Security.MembershipUser

Converts a Member object into a MembershipUser object using its assigned settings

HexToByte ( string hexString ) : byte[]

Converts a string into a byte array

ResetAuthenticationFailures ( Member &m, System.DateTime dt ) : void

Upon a successful login or password reset, this changes all the previous failure markers to defaults.

UnEncodePassword ( string encodedPassword ) : string

Decodes a given stored password into a cleartype or unencrypted form. Provided it isn't hashed.

Method Details

ChangePassword() public method

Change the current password for a new one. Note: Both are required.
public ChangePassword ( string username, string oldPassword, string newPassword ) : bool
username string Username the password is being changed for
oldPassword string Old password to verify owner
newPassword string New password
return bool

ChangePasswordQuestionAndAnswer() public method

Change the password retreival/reset question and answer pair
public ChangePasswordQuestionAndAnswer ( string username, string password, string newPasswordQuestion, string newPasswordAnswer ) : bool
username string Username the question and answer are being changed for
password string Current password
newPasswordQuestion string New password question
newPasswordAnswer string New password answer (will also be encrypted)
return bool

CreateUser() public method

Creates a new user with a given set of default values
public CreateUser ( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, MembershipCreateStatus &status ) : System.Web.Security.MembershipUser
username string
password string
email string
passwordQuestion string
passwordAnswer string
isApproved bool
providerUserKey object
status MembershipCreateStatus
return System.Web.Security.MembershipUser

DeleteUser() public method

Permanently deletes a user from the database
public DeleteUser ( string username, bool deleteAllRelatedData ) : bool
username string Username to delete
deleteAllRelatedData bool Should or shouldn't delete related user data
return bool

FindUsersByEmail() public method

Finds a list of users with a matching email address
public FindUsersByEmail ( string emailToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
emailToMatch string Given email to search
pageIndex int Current page index
pageSize int Number of results per page
totalRecords int Total number of users returned
return System.Web.Security.MembershipUserCollection

FindUsersByName() public method

Gets a list of users with a matching username
public FindUsersByName ( string usernameToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
usernameToMatch string Username to search for
pageIndex int Current page index
pageSize int Number of results per page
totalRecords int Total number of users returned
return System.Web.Security.MembershipUserCollection

GetAllUsers() public method

Gets all the users in the database
public GetAllUsers ( int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
pageIndex int Current page index
pageSize int Number of results per page
totalRecords int Total number of users returned
return System.Web.Security.MembershipUserCollection

GetNumberOfUsersOnline() public method

Gets the total number of users that are currently online.
public GetNumberOfUsersOnline ( ) : int
return int

GetPassword() public method

Gets the current password of a user (provided it isn't hashed)
public GetPassword ( string username, string answer ) : string
username string User the password is being retrieved for
answer string Password retrieval answer
return string

GetUser() public method

Gets a MembershipUser object with a given key
public GetUser ( object providerUserKey, bool userIsOnline ) : System.Web.Security.MembershipUser
providerUserKey object
userIsOnline bool
return System.Web.Security.MembershipUser

GetUser() public method

Gets a MembershipUser object with a given username
public GetUser ( string username, bool userIsOnline ) : System.Web.Security.MembershipUser
username string
userIsOnline bool
return System.Web.Security.MembershipUser

GetUserNameByEmail() public method

Gets the username by a given matching email address
public GetUserNameByEmail ( string email ) : string
email string
return string

Initialize() public method

public Initialize ( string name, System config ) : void
name string
config System
return void

ResetPassword() public method

Resets the passwords with a generated value
public ResetPassword ( string username, string answer ) : string
username string User the password is being reset for
answer string Password retrieval answer
return string

UnlockUser() public method

Unlocks a user (after too many login attempts perhaps)
public UnlockUser ( string userName ) : bool
userName string Username to unlock
return bool

UpdateUser() public method

Updates an existing user with new settings
public UpdateUser ( System.Web.Security.MembershipUser user ) : void
user System.Web.Security.MembershipUser MembershipUser object to modify
return void

ValidateUser() public method

Authenticates a user with the given username and password
public ValidateUser ( string username, string password ) : bool
username string Login password
password string The login username
return bool