Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i change or update password in asp.net membership via sql server

I have to change a password to something else, I have got all the details like userid, username, encrypted password, password format.

How can I change the password via SQL in asp.net membership?

like image 334
Mr A Avatar asked Jan 24 '12 11:01

Mr A


People also ask

How can I reset my asp net membership password?

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


1 Answers

You can use this query;

Declare @UserName NVarChar(30)    
Declare @Password NVarChar(30)    
Declare @Application NVarChar(255)    
Declare @PasswordSalt NVarChar(128)    

set @UserName = 'UserName'    
set @Password = 'Pass'    
set @Application = '/Application'    
Set @PasswordSalt = (SELECT TOP 1 PasswordSalt FROM aspnet_Membership WHERE UserID IN    (SELECT UserID FROM aspnet_Users u, aspnet_Applications a WHERE u.UserName=@UserName and a.ApplicationName = @Application AND u.ApplicationId = a.ApplicationId))    

Exec dbo.aspnet_Membership_ResetPassword @Application, @UserName, @Password, 10, 10, @PasswordSalt, -5    
like image 68
oOZz Avatar answered Sep 18 '22 11:09

oOZz