title: How do I authenticate against Active Directory from ASP.NET web service code?
body: <p>I have a few websites for work that live outside of the corporate LAN -- and, therefore, out of direct-communication range of Active Directory (A/D) -- but for which I would like to be able to authenticate users against the corporate A/D servers as well as a secondary repository of users/roles***. The pseudo code for this activity is this:</p>
  
  <ol>
  <li>User enters username/password into the login form of the external website.</li>
  <li>External website calls a webservice inside the LAN that can talk to A/D.</li>
  <li>The webservice checks to see if username/password can be authenticated mapped to a user in A/D. If so, return the list of A/D roles of which the user is a member.</li>
  <li>If the username/password cannot be found/authenticated against A/D, check a database/service that is the secondary repository of user/role information. Return all roles the use is in if they authenticate against the secondary auth server.</li>
  <li>Return the a list of roles the user is in to the calling website.</li>
  </ol>
  
  <p>*** The idea is that we don't want to put dozens -- potentially hundreds -- of contractors and affiliates into Active Directory when all they will only be logging into our external web servers. Hence the secondary auth scheme.</p>