How can I migrate legacy passwords to SimpleMembership
-
09-07-2021 - |
質問
I have a legacy system which is getting rebuilt in MVC4. I understand how to connect SimpleMembership to my 'users' table, but I'm not sure how to import my existing passwords into the webpages_Membership table (in particular with regard to the password encoding).
How can I migrate my legacy passwords to the new SimpleMembership 'way' ? If possible, I'd like to do this all via SQL code.
Thanks!
解決
This is what I'm going to do:
I'm going to add a "temporary password" column to my "Users" table. On failed login via the standard membership lookup ( WebSecurity.Login()
), I will perform an extra lookup on my "Users" table to match the "UserName" and the "temporary password" with the entered credentials. If I find a match there, then I'll use the WebSecurity methods to create the appropriate membership records, including roles. After successful creation, I'll delete the temporary password.