开发者

ASP.net Memberships Force User Offline (as admin)

开发者 https://www.devze.com 2023-02-08 22:33 出处:网络
I am looking for a way to distroy the ASP.net memb开发者_如何学运维ership session for a specific user.The reason I am doing this is as an admin I want to delete a user. This works fine, but if the use

I am looking for a way to distroy the ASP.net memb开发者_如何学运维ership session for a specific user. The reason I am doing this is as an admin I want to delete a user. This works fine, but if the user already has an active session, he is still marked as "online" until this session dies (I verify each time by using Current.User.Identity.IsAuthenticated).

How do I go about killing a session based on the user it's authorized as. This way when I do Memberships.DeleteUser(username) I can also do Sessions.KillByUser(username)

Thanks in advance


I ended up following their suggestion and using the following method, for anyone who has the same issue: http://www.chillaxen.com/2011/02/asp-net-force-a-user-offline-as-admin-destroy-a-session-by-username/


How about adding a HttpModule which intercept PostAuthorizeRequest event: Check the users' credentials against a global list of IDs you want to "destroy". If there's a match, kill the users session.


As Jakob suggested Or you can try this... in the Global.asax check if the logged in user is in the 'List of user to be made Offline' then logout the user by forms authentication or deleting the cookie.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号