I have this code for changing a user\'s password when they click the password reset button (with extra code to log to ELMAH so I can try to figure out what is going wrong).
Well this is certainly an interesting one. The "it works for some, not for others" part is really bizarre.
Is this an intermittent problem, or does it always occur for certain users, and always not occur for other users?
One of the other people here suggested running ValidateUser(username, newPassword)
to confirm that the user could properly authenticate before assuming success.
Have you tried this? You could continuously loop, resetting + changing the password until ValidateUser is successful, perhaps exiting after N failures.
bool success = false;
int numAttempts = 0;
do
{
string pwd = user.ResetPassword();
if (user.ChangePassword(pwd, confirmPassword))
{
success = Membership.ValidateUser(user.UserName, pwd);
}
numAttempts++;
} while(numAttempts < 5 && !success);
Note: This is not for use in production, just for testing to see if this resolves the problem.