Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devseevali/183869d3c5a45e92c8cd3f9b02d31da1 to your computer and use it in GitHub Desktop.
Save devseevali/183869d3c5a45e92c8cd3f9b02d31da1 to your computer and use it in GitHub Desktop.
Sql Server Membership User: Unlock and Change Password
--Unlock User
DECLARE @return_value int
EXEC @return_value = aspnet_Membership_UnlockUser
@ApplicationName = '/',
@UserName = 'user_name'
SELECT 'Return Value' = @return_value
GO
--Get required details using another known User
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 = 'other_user_name';
-- Change Password
DECLARE @changeDate DATETIME
SET @changeDate = GETDATE()
EXEC aspnet_Membership_setPassword
'applicationName',
'user_name',
'other_user_password',
'other_user_password_salt',
@changeDate,
other_user_passwordformat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment