Class UmbracoMembershipProvider<T, TEntity>
Abstract Membership Provider that users any implementation of IMembershipMemberService{TEntity} service
Inheritance
Namespace: Umbraco.Web.Security.Providers
Assembly: Umbraco.Web.dll
Syntax
public abstract class UmbracoMembershipProvider<T, TEntity> : UmbracoMembershipProviderBase where T : IMembershipMemberService<TEntity> where TEntity : class, IMembershipUser
Type Parameters
Name | Description |
---|---|
T | |
TEntity |
Constructors
View SourceUmbracoMembershipProvider(IMembershipMemberService<TEntity>)
Declaration
protected UmbracoMembershipProvider(IMembershipMemberService<TEntity> memberService)
Parameters
Type | Name | Description |
---|---|---|
IMembershipMemberService<TEntity> | memberService |
Properties
View SourceAllowManuallyChangingPassword
For backwards compatibility, this provider supports this option by default it is false
Declaration
public override bool AllowManuallyChangingPassword { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MemberService
Declaration
protected IMembershipMemberService<TEntity> MemberService { get; }
Property Value
Type | Description |
---|---|
IMembershipMemberService<TEntity> |
ProviderName
Declaration
public abstract string ProviderName { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
View SourceConvertToMembershipUser(TEntity)
Declaration
protected abstract MembershipUser ConvertToMembershipUser(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Returns
Type | Description |
---|---|
System.Web.Security.MembershipUser |
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 | TODO: This setting currently has no effect |
Returns
Type | Description |
---|---|
System.Boolean | true if the user was successfully deleted; otherwise, false. |
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. |
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. |
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. |
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
The way this is done is the same way that it is done in the MS SqlMembershipProvider - We query for any members that have their last active date within the Membership.UserIsOnlineTimeWindow (which is in minutes). It isn't exact science but that is how MS have made theirs so we'll follow that principal.
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. |
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. |
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 | 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. |
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. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The name of the provider is null. |
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. |
System.ArgumentException | The name of the provider has a length of zero. |
PerformChangePassword(String, String, String)
Processes a request to update the password for a membership user.
Declaration
protected override bool PerformChangePassword(string username, string oldPassword, string newPassword)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | The user to update the password for. |
System.String | oldPassword | This property is ignore for this provider |
System.String | newPassword | The new password for the specified user. |
Returns
Type | Description |
---|---|
System.Boolean | true if the password was updated successfully; otherwise, false. |
PerformChangePasswordQuestionAndAnswer(String, String, String, String)
Processes a request to update the password question and answer for a membership user.
Declaration
protected override bool PerformChangePasswordQuestionAndAnswer(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. |
PerformCreateUser(String, String, String, String, String, String, Boolean, Object, out MembershipCreateStatus)
Adds a new membership user to the data source with the specified member type
Declaration
protected override MembershipUser PerformCreateUser(string memberTypeAlias, string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
Parameters
Type | Name | Description |
---|---|---|
System.String | memberTypeAlias | A specific member type to create the member for |
System.String | username | The user name for the new user. |
System.String | password | The password for the new user. |
System.String | 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. |
PerformGetPassword(String, String)
Gets the password for the specified user name from the data source.
Declaration
protected override string PerformGetPassword(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. |
PerformResetPassword(String, String, String)
Resets a user's password to a new, automatically generated password.
Declaration
protected override string PerformResetPassword(string username, string answer, string generatedPassword)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | The user to reset the password for. |
System.String | answer | The password answer for the specified user (not used with Umbraco). |
System.String | generatedPassword |
Returns
Type | Description |
---|---|
System.String | The new password for the specified user. |
UnlockUser(String)
Clears a lock so that the membership user can be validated.
Declaration
public override bool UnlockUser(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | The membership user to clear the lock status for. |
Returns
Type | Description |
---|---|
System.Boolean | true if the membership user was successfully unlocked; otherwise, false. |
UpdateUser(MembershipUser)
Updates e-mail approved status, lock status and comment on a user.
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. |
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. |