C#MembershipUser.ChangePassword失败只有一个用户? [英] C# MembershipUser.ChangePassword fails for one user only?

查看:427
本文介绍了C#MembershipUser.ChangePassword失败只有一个用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的标准AspNetSqlMembershipProvider的更改密码功能在我的ASP.NET MVC 2应用程序:

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
}

和这个工程对于绝大多数用户,但也有几个用户不能更改密码 - user.ChangePassword()刚刚返回false。

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.

我已经尝试过自己,看看发生了什么事情,并进入了一个简单的密码12345678该用户并没有改变

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.

所以,这不是因为他们正进入不符合密码规则的密码。我的web.config中定义,像这样的成员资格提供程序:

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="/" />



它只是AspNetSqlMembershipProvider正常定义,没有什么花哨这里。

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

为什么一个用户(我)能够更改他们的密码是12345678,但其他用户无法更改其密码被12345678?这其他用户不能在所有更改其密码的任何东西。

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 调用的 SqlMembershipProvider.ChangePassword ,它返回如果用户被锁定。

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

这篇关于C#MembershipUser.ChangePassword失败只有一个用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆