views:

2588

answers:

1

Problem, there's no method:

bool ChangePassword(string newPassword);

You have to know the current password (which is probably hashed and forgotten).

+21  A: 

This is an easy one that I wasted too much time on. Hopefully this post saves someone else the pain of slapping their forehead as hard as I did.

Solution, reset the password randomly and pass that into the change method.

MembershipUser u = Membership.GetUser();
u.ChangePassword(u.ResetPassword(), "myAwesomePassword");
mcqwerty
Hey, come on. Don't downvote for answering your own question. The FAQ encourages that. See http://stackoverflow.com/questions/18557/how-does-stackoverflow-work-the-unofficial-faq#119658
DOK
The down-vote (not me!) was before the answer was moved here. Previously it said that the answer was in the question. I'm not too keen on down-voting people who have only just joined SO - it's much better to edit to help out.
harriyott
Yes and he gets the pretty badge too !!
CheGueVerra
@harriyott doh... I think next time one of us should leave a comment indicating we're editing... so we don't waste time doing the same thing.
chakrit
On my app i get this: Value cannot be null.Parameter name: passwordAnswerany ideas??
Andi
Make sure you have this attribute set in your web.config if you get the error above:requiresQuestionAndAnswer="true"
Andi
I wasted a lot of time before I found this answer, thank you.
Frank Schwieterman