Im currently doing an application in .net using c# and I want to use the change password control.
The problem is...I always get an error of "Password incorrect or New Password invalid. New Password length minimum: 1. Non-alphanumeric characters required: 0."
Even if I supplied the correct parameters of the password and set the (minRequiredPasswor开发者_JAVA百科dLength="1" minRequiredNonalphanumericCharacters="0") in Mebership provider in my web.config.
<asp:ChangePassword ID="ChangePassword1" runat="server" BackColor="#EFF3FB" BorderColor="#B5C7DE"
BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="#333333"
ChangePasswordButtonText="Change"
ChangePasswordTitleText="Password change"
ConfirmNewPasswordLabelText="Retype new password:"
NewPasswordLabelText="New Password:">
</asp:ChangePassword>
i'm implementing my own MembershipProvider:
public class MyMembershipProvider : MembershipProvider
{
...
public override int MinRequiredNonAlphanumericCharacters
{
get
{
return 0;
}
}
...
}
The web.config:
<membership defaultProvider="MyMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<add name="MyMembershipProvider"
type="My.Security.BsAsMembershipProvider"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="MyApp"
requiresUniqueEmail="true"
passwordFormat="Clear"
passwordStrengthRegularExpression=""
minRequiredNonalphanumericCharacters="0"
description="My custom membership provider"
/>
</providers>
</membership>
Any ideas? Thanks.
I have found the problem, I had not implemented MyMemberShipUser ChangePassword method.
public class MyMembershipUser : MembershipUser
{
public MyMembershipUser()
{
}
public MyMembershipUser(string username)
: base("MyMembershipProvider", username, null, "", "", "", true, true, DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today)
{
}
public override bool ChangePassword(string oldPassword, string newPassword)
{
//Do something
}
}
精彩评论