title: OWIN with LDAP Authentication
body: <p>Here is my scenario.  I have an MVC 5 application that uses Owin as an authentication mechanism.  The default template calls the SignInManager.PasswordSignInAsync in the Login action which I would like to overwrite to use LDAP to validate the user instead of looking into the database.  </p>
  
  <p>I am able to do the validation via:</p>
  
  <pre><code>PrincipalContext dc = new PrincipalContext(ContextType.Domain, "domain.com", "DC=domain,DC=com", "user_name", "password");
          bool authenticated = dc.ValidateCredentials(userName, password);
  </code></pre>
  
  <p>Then I can retrieve the UserPrincipal using:</p>
  
  <pre><code>UserPrincipal user = UserPrincipal.FindByIdentity(dc, IdentityType.SamAccountName, userName);
  </code></pre>
  
  <p>However, I am stuck here and I am not sure how to continue with signing in the user.  The goal is that after I sign in the user, I would have access to User.Identity including all the roles the user is in.  Essentially, the app should behave as if it uses Windows Authentication, but the credentials are provided by the user on the Login page.  </p>
  
  <p>You would probably ask why not user Windows Authentication directly.  The app will be accessed from the outside of the network, but the requirements are to use AD authentication and authorization.  Hence my predicament.</p>
  
  <p>Any suggestions are highly appreciated.</p>
  
  <p>Thank you.</p>