I want to authenticate using integrated Windows authentication with a single controller in place of a global application. I read many articles on the Internet and StackOverflow, but could not find the answer. Notice that I am developing in Web API 2.0, not MVC.
However, as a general rule, to enable Windows authentication on your entire application, you would do something like Web UI Documentation :
<system.web> <authentication mode="Windows" /> </system.web>
Under the covers, I'm not sure what this does for sure, but I have a suspicion that I can play it on one controller action by doing IAuthenticationFilter as described in the web interface documentation . However, I did not find a convincing article explaining how to do this for Windows Integrated Authentication.
An example of my goal:
At the end of the day, I would like my only web API to accept a request from a client configured to use Windows authentication in any of the following client scenarios:
FROM#
var handler = new HttpClientHandler() { UseDefaultCredentials = true }; var client = new HttpClient(handler);
Browser
$.ajax({ url: 'api/testauthentication', type: 'GET', dataType: 'json', xhrFields: { withCredentials: true } })
Edit # 1
It occurred to me to note that I would like to execute the above programmed and not configuration files such as web.config, IIS settings, etc. In addition, I use OWIN to host the application on my servers.
source share