title: Get currently authenticated user against Active Directory through javascript
body: <p>I'm (we're here at my company) facing a challenge. We're being asked by most of our clients (if not all of them) to automatically authenticate a user with their previously-entered windows authentication, which is going against a LDAP Active Directory. The app is a web app running in .NET webforms, but we're currently in design phase for the second version which will make the jump towards MVC, if that's of any help.</p>
  
  <h1>Behaviour</h1>
  
  <ul>
  <li>User opens a Windows session authenticating against Active Directory</li>
  <li>User opens the browser and goes to his/hers company's installation of our product (most of the time installed in a local server, but it might installed outside)</li>
  <li>The page has to check whether the user is authenticated via Active Directory and, if he/she is, authenticate the user into the app (for the sake of simplicity, the same login name in AD has to be registered in our app in advanced)</li>
  <li>If not (the user didn't login against AD), then prompt for user credentials, and authenticate those credentials against AD.</li>
  </ul>
  
  <p>The problem I'm facing is that I don't know <strong>how to retrieve this 2 things</strong>:</p>
  
  <ul>
  <li><strong><em>Which</em> authentication method</strong> the user used to get in. I actually only need to know if it was through AD or not.</li>
  <li><strong>The username</strong> he/she used (that would be the username of the current windows session).</li>
  </ul>
  
  <p>I'm pretty confident that this would have to be done through javascript, but in case it <strong>can't</strong>, we're ok with developing a little plugin for the browsers to get to the necessary Windows API function.</p>
  
  <p>Please let me know your thoughts on the matter, and whether you need any more information.</p>