2014-04-01 2 views
1

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 }); 
} 
+0

오류가 발생하거나 코드가 정상적으로 실행 되나 암호가 변경되지 않습니까? 또한 사용자가 잠겨 있지 않은지 확인하십시오. – harsimranb

+0

오류를 표시하십시오. –

+0

죄송합니다. 오류없이 false를 반환합니다. 질문을 업데이트했습니다. – WebDevNewbie

답변

1

내부 오픈 ID 공급자를 다시 동일한 DEV 데이터베이스를 사용하고 회사 내에서 다른 사람을 끈다. 이 OpenID Provider 개발 과정에서 데이터가 변경되어 이상한 행동을 일으켰습니다. 고맙게도 방금 일부 데이터 변경 사항을 확인하고 다른 그룹에 대해 질문하여 더 이상 시간을 낭비하지 않게되었습니다 ..

사용자를 검색 할 수 있었지만 암호는 변경하지 못했습니다. 해당 사용자의 결국 두 프로젝트 간의 의사 소통을 정리하면 현재 문제가 해결 된 것 같습니다.

데이터베이스를 공유 할 때 좋은 레슨을 알게되었습니다. 도와 줘서 고맙습니다.

관련 문제