How to Use
Membershipuser
Change Password
Vkvi
Source: Qianyi Network
(Original)
Time:
2009-3-11
Perfect Integration and Enhancement
Kindeditor html
Editor
In
ASP. NET
The change of user password is complicated in the built-in membership.
Membershipuser
There is
Method
Changepassword
You can change the password, but you must first enter the original password. If the user has forgotten the original password,
Ask the Administrator to set a new password.
There are two methods to reset the password without entering the original password:
Method 1
First, in the configuration file
Enablepasswordreset
Set
True
,
Requiresquestionandanswer
Set
False
.
That is to say, allow password reset,
Do not use questions or answers
Return password. About how to set,
See:
ASP. NET
Membership-Configuration
,
In
Membership
For locked use
Reset Password
.
Then the code is:
Membershipuser user = membership. getuser ("
User Name
");
String Password = user. resetpassword ();//
Reset A Random Password
User. changepassword (password ,"
New Password
");//
Set with the specified password
Method 2
In this way, you do not need to disable questions and answers, but you cannot set the password to the password you want to set.
The principle is to update the encrypted string of a known password in the database to the user who wants to change the password. Steps:
?
The username that has lost the password is
Cftea
The username of another user is
Admin
The password is
1234567
,
We can
Aspnet_users
In
Cftea
And
Admin
Of
Userid
.
Computer Level 2 Computer Level 3 Computer Level 4 Computer Level 4 Computer Level 2 Examination
?
Then go to the table
Aspnet_membership
Passed
Userid
Find
Password
And
Passwordsalt
.
?
Set
Admin
Corresponding to that user
Password
And
Passwordsalt
Update
Cftea
Corresponding word
.
?
In this case
Cftea
The password is the same
Admin
Same.
If multiple applications use the same library,
First come
Aspnet_applications
Searching
To the corresponding application
Applicationid
And then
Aspnet_users
Search
Userid
The
Applicationid
Also
Where
Add conditions.
How to Use membershipuser To Change Password