System.Web.Security.MembershipUser와 함께 System.Web.Providers.DefaultMembershipProvider를 사용하여 데이터베이스에서 사용자 암호를 변경하려고합니다. 어떤 이유로 든 내가하는 일에 상관없이 MembershipUser.ChangePassword (old, new)는 오류없이 false를 반환합니다.MembershipUser.ChangePassword가 항상 false를 반환합니다.
데이터베이스에서 응용 프로그램 이름과 연결된 내 ApplicationID가 정확하며 내 사용자의 ApplicationID가 Memberships 및 Users 테이블에 연결되어 있습니다. 그 시점에서 사용자가 null이 아니기 때문에 모든 데이터가 객체에서 정확합니다. 나는 완전한 손실을 입었습니다. 어떤 도움도 다른 도움을 줄 수 없기 때문에 큰 도움이 될 것입니다.
EDIT:
User is not locked out, the user is active, and the password is correct. All
password requirements are being fulfilled. This is extremely frustrating since
the MembershipUser.GetUser() finds the user and all of its associated data but
will not change the password.
Additional Steps:
- Tried MembershipUser.UnlockUser() just in case, no luck.
- Tried MembershipUser.ResetPassword() then a change. This fails with the
error message "Value cannot be null" even though it should be able to.
- GetSpecificVerion of the entire solution and working to when it first
broke. Every version worked, including my latest (Yay!), but then it
magically stopped working again a few minutes later, no code changes
were made at all.
Bounty added, looking for any and all possibilities that could lead to a fix...
구성 파일 :
----
<add name="aspnetdb" connectionString="Application Name=appname;Type System Version=SQL Server 2008;server=***,****;Initial Catalog=aspnetdb;Integrated Security=false;pwd=****;user id=****" providerName="System.Data.SqlClient" />
----
----
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="aspnetdb" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" passwordAttemptWindow="10" applicationName="mysite.com" />
</providers>
</membership>
----
방법 :
public ActionResult ChangePassword(ChangePasswordViewModel model)
{
// Indicates whether changing the password was successful or not.
Boolean passwordChanged = false;
if (ModelState.IsValid)
{
// Grab the current user.
MembershipUser user = Membership.GetUser(User.Identity.Name, true);
if (user != null)
{
passwordChanged = user.ChangePassword(model.OldPassword, model.NewPassword);
}
}
return Json(new { Success = passwordChanged });
}
오류가 발생하거나 코드가 정상적으로 실행 되나 암호가 변경되지 않습니까? 또한 사용자가 잠겨 있지 않은지 확인하십시오. – harsimranb
오류를 표시하십시오. –
죄송합니다. 오류없이 false를 반환합니다. 질문을 업데이트했습니다. – WebDevNewbie