November Happy Hour will be moved to Thursday December 5th.

Class WindowsMembershipProvider

A Windows membership provider that will support "offline" role membership requests with the corresponding WindowsRoleProvider.

Inheritance
System.Object
WindowsMembershipProvider
Namespace: EPiServer.Security
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
[ProviderCapability((ProviderActions)0)]
public class WindowsMembershipProvider : MembershipProvider

Constructors

WindowsMembershipProvider()

Initializes a new instance of the WindowsMembershipProvider class.

Declaration
public WindowsMembershipProvider()

Properties

ApplicationName

The name of the application using the custom membership provider.

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

The current implementation ignores the ApplicationName. All users are placed in the same store regardless of the ApplicationName. Since the windows account database is the same regardless of the application in use it makes no sense to partition the user store.

DeletePrefix

Gets or sets the delete prefixes.

Declaration
public string[] DeletePrefix { get; set; }
Property Value
Type Description
System.String[]

The delete prefixes.

Remarks

When reading the Windows groups there are some group names that have prefixes that you may want to remove. For example the Administrators group is reported as "BUILTIN\Administrators" and by setting the DeletePrefix to "BUILTIN" the group will instead be reported as "Administrators".

The primary way to set this property is by setting the attribute deletePrefix for the membership provider configuration in web.config. The attribute is a comma-separated string with the prefixes to check.

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

EnablePasswordRetrieval

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

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

MaxInvalidPasswordAttempts

Not supported by this provider. 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

MinRequiredNonAlphanumericCharacters

Not supported by this provider. 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

MinRequiredPasswordLength

Not supported by this provider. Gets the minimum length required for a password.

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

PasswordAttemptWindow

Not supported by this provider. 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

PasswordFormat

Gets the format of the password

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

PasswordStrengthRegularExpression

Not supported by this provider. Gets the regular expression used to evaluate a password.

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

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

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

Methods

ChangePassword(String, String, String)

Not supported by this provider. 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.

ChangePasswordQuestionAndAnswer(String, String, String, String)

Not supported by this provider. 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.

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

Not supported by this provider. 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.

DeleteUser(String, Boolean)

Not supported by this provider. 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.

FindUsersByEmail(String, Int32, Int32, out Int32)

Supported by this provider only if the searchByEmail is set to True. 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.

GetDeletePrefix()

Gets the delete prefixes.

Declaration
public static string[] GetDeletePrefix()
Returns
Type Description
System.String[]

GetNumberOfUsersOnline()

Not supported by this provider. 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.

GetPassword(String, String)

Not supported by this provider. 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.

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)

Not supported by this provider. 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.

GroupNamesFromIdentity(WindowsIdentity)

Get names of the groups that the WindowsIdentity belongs to.

Declaration
public static string[] GroupNamesFromIdentity(WindowsIdentity identity)
Parameters
Type Name Description
System.Security.Principal.WindowsIdentity identity

The identity.

Returns
Type Description
System.String[]

A string[] with the groups names.

GroupNamesFromIdentity(WindowsIdentity, String[])

Get names of the groups that the WindowsIdentity belongs to.

Declaration
public static string[] GroupNamesFromIdentity(WindowsIdentity identity, string[] deletePrefix)
Parameters
Type Name Description
System.Security.Principal.WindowsIdentity identity

The identity.

System.String[] deletePrefix

The delete prefix.

Returns
Type Description
System.String[]

A string[] with the groups names.

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.

ResetPassword(String, String)

Not supported by this provider. 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.

UnlockUser(String)

Not supported by this provider. 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)

Not supported by this provider. 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.

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.

Extension Methods