title: Hooking into Windows Authentication for credentials when Authenticating against LDAP
body: <p>I have a web-portal for employees to update their details. People login there with their Active Directory credentials and I set OWIN cookie for authentication. This is all done through a MVC login page, nothing to do with Windows Authentication on IIS.</p>
  
  <p>Now company browser is Internet Explorer and is configured to login automatically into other Windows Authentication sites, without prompting for password. That is happening when people are using company PC and logged into their domain accounts. And if they are working from home, Basic Authentication prompt is asking for credentials on these systems.</p>
  
  <p>Now I would like to implement an automatic authentication when users are logged-in into their Windows Domain accounts, from work PCs, and present with login-page if they are working from home. </p>
  
  <p>I know about 401 challenge and authentication negotiation, but never initiated with this through ASP.Net. I've seen solutions where user is redirected to a page where IIS is configured to be Windows Authentication, but I want this done without IIS configuration. Also I remember I have seen somebody mentioning a solution where a page is loaded into <code>&lt;iframe&gt;</code> where basic authentication is checked and if authentication through that is successful, then redirect already authenticated user to a landing page.</p>
  
  <p>So my question comes down to: <strong>Is there a way to initiate (and complete) 401 challenge for basic authentication on a specific action of a controller? And then hook into <code>Controller.User.Identity</code> property to set OWIN cookie?</strong></p>
  
  <p><strong>UPD:</strong>
  As per comments: I want Kerberos (Windows Authentication) to work when users are on domain network, so they are automatically logged-in. But I don't want Windows Authentication to take place when users are not on domain network, instead I want custom login page with options for password reset and register (given employee validation).</p>