Saturday, June 22, 2013

Update or Change password in ASP.net Using SQL Server

From the below stackoverflow answer i got a usefull tip to change/reset password using sql server.
Please refer the following stackoverflow questions and answers for more details
http://stackoverflow.com/questions/8986294/how-can-i-change-or-update-password-in-asp-net-membership-via-sql-server
http://stackoverflow.com/questions/287320/how-do-you-change-a-hashed-password-using-asp-net-membership-provider-if-you-don?lq=1

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 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