With custom UserNamePasswordValidator, can I kill the user's WPF “session”?

前端 未结 2 1957
逝去的感伤
逝去的感伤 2021-01-23 18:22

I\'m using a custom UserNamePasswordValidator, which instantiates and logs in to our internal API.

This API exposes an event that\'s fired when the user is \"kicked\" (b

2条回答
  •  暖寄归人
    2021-01-23 18:57

    I found some code at http://www.neovolve.com/post/2008/04/07/wcf-security-getting-the-password-of-the-user.aspx that shows how to use a custom ServiceCredentials class and, from there, passing the user's details all the way through to Thread.CurrentPrinciple.

    Starting from that code, I've stashed the Connection object in a custom principal object, which means that I can get to it in a session context. Then, I added a custom CodeAccessSecurityAttribute that checks that connection object to see if it's been disconnected. If it has, an exception is thrown, which kills the user's session.

提交回复
热议问题