ASP.Net Identity Force从SQL注销 [英] ASP.Net Identity Force Logout From SQL

查看:48
本文介绍了ASP.Net Identity Force从SQL注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的MVC 5应用程序使用ASPNET标识表.每天晚上,我们在数据库上执行维护".如果我们在该用户下进行了某些修改,则我想取消其当前会话,以使他们在Web应用程序中执行的下一个操作会将他们踢回到登录屏幕.身份验证/授权已使用AspNet.Identity内置到我的应用程序中.我只需要一种方法来设置它(如果存在)来唤醒它.

I'm using the ASPNET Identity tables for my MVC 5 application. Each night we perform "maintenance" on our database. If we modify something under that user, I want to inactivate their current session so that the next action they perform in the web application will kick them back to the login screen. The authentication/authorization already is built into my application using AspNet.Identity. I just need a way to wake it up by setting a flag if it exists.

例如,ASPNETUsers表具有不活动"列,但这太永久了.我正在寻找"ThisGuyIsLoggedIn"列.

For example the ASPNETUsers table has an "Inactive" column, but that's too permanent. I'm looking for the "ThisGuyIsLoggedIn" column.

这接近于相同的问题,但是答案是从MVC内部进行管理,这不是一个选择.

This was close to the same problem, but the answer was to manage it from within MVC, which is not an option.

在所有在线用户中强制注销特定用户用户

推荐答案

使用我意识到的一些列后,您可以更改SecurityStamp列,该列将使用户无效并导致任何身份验证失败.只是不要将其更改为NULL.

After playing with some of the columns I realized, you can change the SecurityStamp column which will invalidate the user and cause any authentication to fail. Just don't change it to NULL.

 UPDATE AspNetUsers
 SET SecurityStamp = NEWID()
 WHERE Id = @USER_ID

这篇关于ASP.Net Identity Force从SQL注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆