Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually change password in asp.net membership?

I would like to change password in database manually, but I am not sure what exactly I need to change and which methods to use. I would change it via code but currently I have only access to db.

like image 692
ilija veselica Avatar asked Sep 05 '11 08:09

ilija veselica


People also ask

How to Change password in ASP net Membership?

MembershipUser usr = Membership. GetUser(username); string resetPwd = usr. ResetPassword(); usr. ChangePassword(resetPwd, newPassword);

How can I reset my asp net password?

Local users who forget their password can have a security token sent to their email account, enabling them to reset their password. The user will soon get an email with a link allowing them to reset their password. Selecting the link will take them to the Reset page.

What is membership database in asp net?

ASP.NET provides build in control to validate and store user credential. So, membership helps to manage user authentication and authorization in website. The membership provider is the glue between Login controls and membership database.


2 Answers

See this page: https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-security/admin/recovering-and-changing-passwords-cs

The code calls a stored procedure:

Like with the other methods in the Membership framework, the ResetPassword method delegates to the configured provider. The SqlMembershipProvider invokes the aspnet_Membership_ResetPassword stored procedure, passing in the user's username, the new password, and the supplied password answer, among other fields. The stored procedure ensures that the password answer matches and then updates the user's password.

like image 139
Willem Avatar answered Sep 23 '22 02:09

Willem


If you want to change the password directly through the database, you are going to need to create a new user or find an existing user that you know the password of. Then, you'll need to get the password and salt, then update the user in question with the same password and salt.

Get the user's password/salt:

SELECT 
    au.username, aa.ApplicationName, password, passwordformat, passwordsalt
FROM 
    aspnet_membership am
INNER JOIN 
    aspnet_users au ON (au.userid = am.userid)
INNER JOIN 
    aspnet_applications aa ON (au.applicationId = aa.applicationid)
WHERE
    au.UserName = '[user to change password]'

Change the password:

DECLARE @changeDate DATETIME
SET @changeDate = GETDATE()

EXEC aspnet_Membership_setPassword 
    'applicationName',
    'user',
    'password',
    'passwordsalt',
    @changeDate,
    Passwordformat

Taken from here...

like image 41
Sumo Avatar answered Sep 24 '22 02:09

Sumo