有没有办法只使用SQL重置用户密码(在AspNetUsers表中)?我在MVC 5中使用ASP.NET身份(表单身份验证)。
答案 0 :(得分:1)
添加一些简单的用户并获取用户密码哈希和安全戳,接下来使用SQL查询如下:
USE [Your database name]
GO
UPDATE [dbo].[Users]
SET [UserId] = <UserId, nvarchar(128),>
,[Email] = <Email, nvarchar(256),>
,[EmailConfirmed] = <EmailConfirmed, bit,>
,[PasswordHash] = <PasswordHash, nvarchar(max),> // Your password here
,[SecurityStamp] = <SecurityStamp, nvarchar(max),> // Security stamp here
,[PhoneNumber] = <PhoneNumber, nvarchar(max),>
,[PhoneNumberConfirmed] = <PhoneNumberConfirmed, bit,>
,[TwoFactorEnabled] = <TwoFactorEnabled, bit,>
,[LockoutEndDateUtc] = <LockoutEndDateUtc, datetime,>
,[LockoutEnabled] = <LockoutEnabled, bit,>
,[AccessFailedCount] = <AccessFailedCount, int,>
,[UserName] = <UserName, nvarchar(256),>
,[Discriminator] = <Discriminator, nvarchar(128),>
WHERE <Search Conditions,,> // here place Your user Id
GO
因此,您的用户密码将会更新。