title: ASP.NET Application to authenticate to Active Directory or SQL via Windows Authentication or Forms Authentication
body: <p>I am in the process of writing an application that will need multiple forms of authentication.</p>
  
  <p>The application will need to support authentication to Active Directory, but be able to fail back to a SQL Membership Provider if the user is not in Active Directory.  We can handle the failing to the SQL Provider in code based on the username provided because the username will be a different format than the Active Directory username.</p>
  
  <p>Is this even possible?  What I mean is, can I use membership and use both ActiveDirectoryMembershipProvider and SqlMembershipProvider together or will I have to roll my own?</p>
  
  <p>Another additional added complexity is that I would like to automatically authenticate my internal users based of Windows Authentication back to AD, but use Forms Authentication for users not on our internal network, or users that are using the SQL Provider.</p>
  
  <p>These will most likely be separate servers, one internal, and the other external so I have a lot of planning to do to figure out the data replication, and how I will authenticate the AD users if they hit the outside server etc. </p>
  
  <p>I am wondering what thoughts are out there as I start down this road.  Is what I am wanting to do even possible without me rolling my own, or is there a way to mesh these together?</p>
  
  <hr>
  
  <p>Thanks for the reply.  </p>
  
  <p>The reason I asked originally was because I was able to get this specific senerio working about 7 years ago using IIS to authenticate and then passing back the credentials to a Lotus Domino Server Web App.  If the user was not authenticated via the Windows Authentication/ISS then Domino would handle the authentication.  This was what I was looking to do here, but really couldn't think of a way to make it work in IIS.</p>
  
  <p>As for the rest of your reply, I think you are on to the way that I will need to take.  I have thought this through and tossed it around in my head a lot.  The application will be somewhat different on the two servers anyway since there is going to be limited access to the data on the external server anyway.  The fact that so much is going to be different already I may just treat these as two applications, thus negating the need to use two types of authentication in the same application anyway.</p>
  
  <p>I am playing around with the idea already of writing my own authentication/login window for the external server, and if the user trys to log in with their AD credentials on the external server I will be able to detect that and redirect them to the internal server.  If they are not  on the local network or VPN'd in they will simply not get access.  This part still has some thought process to go though so I am not sure.</p>
  
  <p>As an additional thought - is there a way to pull just enough of AD into a SQL database to allow me to authenticate users to the SQL database from the external server using their AD credentials, without creating any security issues?  I hope I am clearly typing what I am thinking....</p>
  
  <p>Thanks again!</p>
  
  <p>Tim</p>