How to determine which authentication method is used?

有些话、适合烂在心里 提交于 2019-12-13 14:51:55

问题


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.


回答1:


You can check what's on the web config using configuration manager

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



回答2:


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




回答3:


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. :)



来源:https://stackoverflow.com/questions/26976866/how-to-determine-which-authentication-method-is-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!