Class MultiplexingMembershipProvider

A membership provider implementation that acts as a multiplexer between a number of preconfigured membership providers.

Inheritance
System.Object
MultiplexingMembershipProvider
Namespace: EPiServer.Security
Assembly: EPiServer.Framework.AspNet.dll
Version: 11.20.7
Syntax
public class MultiplexingMembershipProvider : MembershipProvider

Constructors

MultiplexingMembershipProvider()

Creates a new instance of MultiplexingMembershipProvider class.

Declaration
public MultiplexingMembershipProvider()

Properties

ActiveMembershipProviders

The list of membership providers that are participating in the multiplexing procedure

Declaration
[Obsolete("This property has been replaced with Providers that is read-only", true)]
public List<MembershipProvider> ActiveMembershipProviders { get; }
Property Value
Type Description
System.Collections.Generic.List<System.Web.Security.MembershipProvider>

ApplicationName

The name of the application using the custom membership provider.

Declaration
public override string ApplicationName { get; set; }
Property Value
Type Description
System.String

CurrentMembershipUser

The membership user based on CurrentUsername

Declaration
public MembershipUser CurrentMembershipUser { get; set; }
Property Value
Type Description
System.Web.Security.MembershipUser

CurrentProvider

Provider to use based on CurrentUsername / CurrentMembershipUser

Declaration
public MembershipProvider CurrentProvider { get; set; }
Property Value
Type Description
System.Web.Security.MembershipProvider

CurrentUsername

Gets or sets current user

Declaration
public string CurrentUsername { get; set; }
Property Value
Type Description
System.String

DefaultProvider

Returns default provider that corresponding to provider1 setting in web.config.

Declaration
public MembershipProvider DefaultProvider { get; }
Property Value
Type Description
System.Web.Security.MembershipProvider

The default provider.

Remarks

The default role provider is used for operations such as adding a new role, where you cannot apply the operation to all providers, neither determine the role provider based on information from the multiplexing membership provider.

EnablePasswordReset

Indicates whether the membership provider is configured to allow users to reset their passwords.

Declaration
public override bool EnablePasswordReset { get; }
Property Value
Type Description
System.Boolean
Remarks

Will use the DefaultProvider for reading the setting.

EnablePasswordRetrieval

Indicates whether the membership provider is configured to allow users to retrieve their passwords.

Declaration
public override bool EnablePasswordRetrieval { get; }
Property Value
Type Description
System.Boolean
Remarks

Will use the DefaultProvider for reading the setting.

MaxInvalidPasswordAttempts

Gets the number of invalid password or password-answer attempts allowed before the membership user is locked out.

Declaration
public override int MaxInvalidPasswordAttempts { get; }
Property Value
Type Description
System.Int32
Remarks

Will use the DefaultProvider for reading the setting.

MembershipProviders

The collection of configured membership providers

Declaration
public MembershipProviderCollection MembershipProviders { get; set; }
Property Value
Type Description
System.Web.Security.MembershipProviderCollection
Remarks

Basically a wrapper around System.Web.Security.Membership.Providers but with the option of doing dependency injection to set your own set of membership providers.

MinRequiredNonAlphanumericCharacters

Gets the minimum number of special characters that must be present in a valid password.

Declaration
public override int MinRequiredNonAlphanumericCharacters { get; }
Property Value
Type Description
System.Int32
Remarks

Will use the DefaultProvider for reading the setting.

MinRequiredPasswordLength

Gets the minimum length required for a password.

Declaration
public override int MinRequiredPasswordLength { get; }
Property Value
Type Description
System.Int32
Remarks

Will use the DefaultProvider for reading the setting.

PasswordAttemptWindow

Gets the number of minutes in which a maximum number of invalid password or password-answer attempts are allowed before the membership user is locked out.

Declaration
public override int PasswordAttemptWindow { get; }
Property Value
Type Description
System.Int32
Remarks

Will use the DefaultProvider for reading the setting.

PasswordFormat

Gets a value indicating the format for storing passwords in the membership data store.

Declaration
public override MembershipPasswordFormat PasswordFormat { get; }
Property Value
Type Description
System.Web.Security.MembershipPasswordFormat
Remarks

Will use the DefaultProvider for reading the setting.

PasswordStrengthRegularExpression

Gets the regular expression used to evaluate a password.

Declaration
public override string PasswordStrengthRegularExpression { get; }
Property Value
Type Description
System.String
Remarks

Will use the DefaultProvider for reading the setting.

Providers

The list of membership providers that are participating in the multiplexing procedure

Declaration
public IList<MembershipProvider> Providers { get; }
Property Value
Type Description
System.Collections.Generic.IList<System.Web.Security.MembershipProvider>

RequiresQuestionAndAnswer

Gets a value indicating whether the membership provider is configured to require the user to answer a password question for password reset and retrieval.

Declaration
public override bool RequiresQuestionAndAnswer { get; }
Property Value
Type Description
System.Boolean
Remarks

Will use the DefaultProvider for reading the setting.

RequiresUniqueEmail

Gets a value indicating whether the membership provider is configured to require a unique e-mail address for each user name.

Declaration
public override bool RequiresUniqueEmail { get; }
Property Value
Type Description
System.Boolean
Remarks

Will use the DefaultProvider for reading the setting.

Methods

ChangePassword(String, String, String)

Processes a request to update the password for a membership user.

Declaration
public override bool ChangePassword(string username, string oldPassword, string newPassword)
Parameters
Type Name Description
System.String username

The user to update the password for.

System.String oldPassword

The current password for the specified user.

System.String newPassword

The new password for the specified user.

Returns
Type Description
System.Boolean

true if the password was updated successfully; otherwise, false.

Remarks

Will use the first active provider where username is found.

ChangePasswordQuestionAndAnswer(String, String, String, String)

Processes a request to update the password question and answer for a membership user.

Declaration
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
Parameters
Type Name Description
System.String username

The user to change the password question and answer for.

System.String password

The password for the specified user.

System.String newPasswordQuestion

The new password question for the specified user.

System.String newPasswordAnswer

The new password answer for the specified user.

Returns
Type Description
System.Boolean

true if the password question and answer are updated successfully; otherwise, false.

Remarks

Will use the first active provider where username is found.

CreateUser(String, String, String, String, String, Boolean, Object, out MembershipCreateStatus)

Adds a new membership user to the data source.

Declaration
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
Parameters
Type Name Description
System.String username

The user name for the new user.

System.String password

The password for the new user.

System.String email

The e-mail address for the new user.

System.String passwordQuestion

The password question for the new user.

System.String passwordAnswer

The password answer for the new user

System.Boolean isApproved

Whether or not the new user is approved to be validated.

System.Object providerUserKey

The unique identifier from the membership data source for the user.

System.Web.Security.MembershipCreateStatus status

A System.Web.Security.MembershipCreateStatus enumeration value indicating whether the user was created successfully.

Returns
Type Description
System.Web.Security.MembershipUser

A System.Web.Security.MembershipUser object populated with the information for the newly created user.

Remarks

Will use the DefaultProvider for creating a new user.

DeleteUser(String, Boolean)

Removes a user from the membership data source.

Declaration
public override bool DeleteUser(string username, bool deleteAllRelatedData)
Parameters
Type Name Description
System.String username

The name of the user to delete.

System.Boolean deleteAllRelatedData

true to delete data related to the user from the database; false to leave data related to the user in the database.

Returns
Type Description
System.Boolean

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

Remarks

Will use the first active provider where username is found.

FindMembershipUser(String)

Gets membership user for provided username

Declaration
public MembershipUser FindMembershipUser(string username)
Parameters
Type Name Description
System.String username

Username

Returns
Type Description
System.Web.Security.MembershipUser

FindUsersByEmail(String, Int32, Int32, out Int32)

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

Declaration
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
Parameters
Type Name Description
System.String emailToMatch

The e-mail address to search for.

System.Int32 pageIndex

The index of the page of results to return. pageIndex is zero-based.

System.Int32 pageSize

The size of the page of results to return.

System.Int32 totalRecords

The total number of matched users.

Returns
Type Description
System.Web.Security.MembershipUserCollection

A System.Web.Security.MembershipUserCollection collection that contains a page of pageSizeSystem.Web.Security.MembershipUser objects beginning at the page specified by pageIndex.

Remarks

Will return data from each provider in order.

FindUsersByName(String, Int32, Int32, out Int32)

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

Declaration
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
Parameters
Type Name Description
System.String usernameToMatch

The user name to search for.

System.Int32 pageIndex

The index of the page of results to return. pageIndex is zero-based.

System.Int32 pageSize

The size of the page of results to return.

System.Int32 totalRecords

The total number of matched users.

Returns
Type Description
System.Web.Security.MembershipUserCollection

A System.Web.Security.MembershipUserCollection collection that contains a page of pageSizeSystem.Web.Security.MembershipUser objects beginning at the page specified by pageIndex.

Remarks

Will return data from each provider in order.

GetAllUsers(Int32, Int32, out Int32)

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

Declaration
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
Parameters
Type Name Description
System.Int32 pageIndex

The index of the page of results to return. pageIndex is zero-based.

System.Int32 pageSize

The size of the page of results to return.

System.Int32 totalRecords

The total number of matched users.

Returns
Type Description
System.Web.Security.MembershipUserCollection

A System.Web.Security.MembershipUserCollection collection that contains a page of pageSizeSystem.Web.Security.MembershipUser objects beginning at the page specified by pageIndex.

Remarks

Will return data from each provider in order.

GetNumberOfUsersOnline()

Gets the number of users currently accessing the application.

Declaration
public override int GetNumberOfUsersOnline()
Returns
Type Description
System.Int32

The number of users currently accessing the application.

Remarks

Will return the sum of online users from all active providers.

GetPassword(String, String)

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

Declaration
public override string GetPassword(string username, string answer)
Parameters
Type Name Description
System.String username

The user to retrieve the password for.

System.String answer

The password answer for the user.

Returns
Type Description
System.String

The password for the specified user name.

Remarks

Will use the first active provider where username is found.

GetUser(Object, Boolean)

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

Declaration
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
Parameters
Type Name Description
System.Object providerUserKey

The unique identifier for the membership user to get information for.

System.Boolean userIsOnline

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.

Returns
Type Description
System.Web.Security.MembershipUser

A System.Web.Security.MembershipUser object populated with the specified user's information from the data source.

Remarks

Will use the first active provider where username is found.

GetUser(String, Boolean)

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

Declaration
public override MembershipUser GetUser(string username, bool userIsOnline)
Parameters
Type Name Description
System.String username

The name of the user to get information for.

System.Boolean userIsOnline

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.

Returns
Type Description
System.Web.Security.MembershipUser

A System.Web.Security.MembershipUser object populated with the specified user's information from the data source.

Remarks

Will use the first active provider where username is found.

GetUserNameByEmail(String)

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

Declaration
public override string GetUserNameByEmail(string email)
Parameters
Type Name Description
System.String email

The e-mail address to search for.

Returns
Type Description
System.String

The user name associated with the specified e-mail address. If no match is found, return null.

Remarks

Will use the first active provider where email is found.

Initialize(String, NameValueCollection)

Initializes MultiplexingMembershipProvider

Declaration
public override void Initialize(string name, NameValueCollection config)
Parameters
Type Name Description
System.String name

Name of provider

System.Collections.Specialized.NameValueCollection config

Collection of name-value pairs

ResetPassword(String, String)

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

Declaration
public override string ResetPassword(string username, string answer)
Parameters
Type Name Description
System.String username

The user to reset the password for.

System.String answer

The password answer for the specified user.

Returns
Type Description
System.String

The new password for the specified user.

Remarks

Will use the first active provider where username is found.

UnlockUser(String)

Unlocks the user.

Declaration
public override bool UnlockUser(string userName)
Parameters
Type Name Description
System.String userName

The username.

Returns
Type Description
System.Boolean
Remarks

Will use the first active provider where username is found.

UpdateUser(MembershipUser)

Updates information about a user in the data source.

Declaration
public override void UpdateUser(MembershipUser user)
Parameters
Type Name Description
System.Web.Security.MembershipUser user

A System.Web.Security.MembershipUser object that represents the user to update and the updated information for the user.

Remarks

Will use the first active provider where username is found.

ValidateUser(String, String)

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

Declaration
public override bool ValidateUser(string username, string password)
Parameters
Type Name Description
System.String username

The name of the user to validate.

System.String password

The password for the specified user.

Returns
Type Description
System.Boolean

true if the specified username and password are valid; otherwise, false.

Remarks

Will use the first active provider where username is found.

Extension Methods