C#如果插入智能卡,则从身份获取用户名

时间:2017-05-05 06:36:08

标签: c# model-view-controller smartcard asp.net-identity-2

我有一个MVC项目,用户目前可以通过他们的身份自动登录。

此网站的用户只能使用智能卡登录其计算机,因此我只需使用HttpContext.User.Identity.Name在门户网站中获取用户名,该用户名将用作各种API调用的参数。

现在这已经改变,现在他们可以使用智能卡或非个人AD用户登录他们的计算机。我需要更改逻辑,所以如果他们不使用智能卡我需要显示登录视图。

我想做的伪代码:

if(SmartCardInserted)
{
username = HttpContext.User.Identity.Name
}
else
{
//redirect to login page and get username from there
}

我的问题是我找不到SmartCardInserted的简单解决方案,我只需要知道是否插入了智能卡。我怎么能这样做?

0 个答案:

没有答案
相关问题