简体   繁体   English

如何确定使用哪种身份验证方法?

[英]How to determine which authentication method is used?

I was wondering: How can i determine which authentication method is in use? 我想知道:我如何确定使用哪种身份验证方法?

For example I want to execute a code if my Authentication is based on FORMS authentication and not if it's WINDOWS Authentication. 例如,如果我的身份验证基于FORMS身份验证而不是WINDOWS身份验证,我想执行代码。

您可以使用配置管理器检查Web配置中的内容

ConfigurationManager.GetSection("system.web/authentication");

You can retrieve a string property called AuthenticationType on your user's identity object: User.Identity.AuthenticationType . 您可以在用户的​​标识对象上检索名为AuthenticationType的字符串属性: User.Identity.AuthenticationType

More documentation here: http://msdn.microsoft.com/en-us/library/system.security.principal.iidentity.authenticationtype(v=vs.110).aspx 这里有更多文档: http//msdn.microsoft.com/en-us/library/system.security.principal.iidentity.authenticationtype(v=vs.110).aspx

You need to have both the Windows Authentication and Forms Authentication both. 您需要同时具有Windows身份验证和表单身份验证。 For this you need to configure your IIS. 为此,您需要配置IIS。 Though it is very difficult to implement. 虽然实施起来非常困难。 http://mvolo.com/iis-70-twolevel-authentication-with-forms-authentication-and-windows-authentication/ Check the above blog and the below discussion:- MVC3 mixed forms and Windows authentication Hope this would help ypu anyway. http://mvolo.com/iis-70-twolevel-authentication-with-forms-authentication-and-windows-authentication/查看上面的博客和下面的讨论: - MVC3混合表单和Windows身份验证希望这对ypu无论如何都有帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM