Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I control the format MembershipUser.ResetPassword()

Is it possible to control the format of the password that is automatically generated by a call to MembershipUser.ResetPassword()?

I want to be able to allow or not allow certain special characters in the generated password.

I am using the SqlMembershipProvider with a password format of Hashed.

Thanks.

like image 903
Andrew Hanson Avatar asked Jan 09 '09 02:01

Andrew Hanson


1 Answers

You may want to do this in two steps, as identified by Mark Fitzpatrick here: http://bytes.com/groups/net-asp/689452-how-reset-users-password-without-having-use-passwordrecovery#post2740740

First Reset the password, then immediately change it to a format of your liking. Obviously using a fixed string as in Mark's example would NOT be recommended - you'd want to implement some random string generator.

user.ChangePassword(user.ResetPassword(), MyMethodToGenerateRandomPassword());
like image 99
Oskar Austegard Avatar answered Sep 29 '22 03:09

Oskar Austegard