简体   繁体   中英

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.

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

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

You can retrieve a string property called AuthenticationType on your user's identity object: User.Identity.AuthenticationType .

More documentation here: 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. For this you need to configure your 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. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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