开发者

C# MembershipUser.ChangePassword fails for one user only?

开发者 https://www.devze.com 2023-01-21 05:28 出处:网络
I\'m using the change password feature of the standard AspNetSqlMembershipProvider in my ASP.NET MVC-2 app:

I'm using the change password feature of the standard AspNetSqlMembershipProvider in my ASP.NET MVC-2 app:

MembershipUser user = Membership.GetUser(userId);
string pwd = user.ResetPassword();
if (user.ChangePassword(pwd, confirmPassword))
{
    // it worked
}

And this works for the vast majority of users, but there are a couple of users that can not change their passwords - user.ChangePassword() just returns false.

I've tried it myself to see what was going on, and entered a simple password 12345678 for that user and it failed to change.

So it's not because they are entering passwords that do not match the password rules. My web.config has the membership provider defined like so:

<add name="AspNetSqlMembershipProvider" type="开发者_开发问答System.Web.Security.SqlMembershipProvider" 
connectionStringName="MembershipDatabaseConnectionString" enablePasswordRetrieval="false" 
enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" 
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" 
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />

Its just the normal definition of AspNetSqlMembershipProvider, there's nothing fancy here.

Why would one user (me) be able to change their password to be 12345678, but another user can not change their password to be 12345678? This other user can not change their password to anything at all.


It sounds like those users are locked out.

MembershipUser.ChangePassword calls SqlMembershipProvider.ChangePassword, which returns false if the user is locked out.

0

精彩评论

暂无评论...
验证码 换一张
取 消