title: Automatic or manual Active Directory authentication in asp.net mvc
body: <p>I'm working on an asp.net mvc web app that is supposed to:</p>
  
  <ol>
  <li>Automatically login someone if they are a valid user in Active Directory.</li>
  <li>If the client is outside of the network (they're at home or whatever), allow them to manually login with their AD credentials through a login form.</li>
  </ol>
  
  <p>I'm very new to AD authentication, I'm confused as to if I should be using Forms Authentication or Windows Authentication.</p>
  
  <p>I have this in my web.config:</p>
  
  <pre><code> &lt;add name="ADConnect" connectionString="LDAP://[something]/CN=dhr,DC=[something],DC=net"  /&gt;
  </code></pre>
  
  <p>If I set: <code>&lt;authentication mode="Windows"&gt;</code>
  I can check User.Identity.IsAuthenticated in the controller to determine if they're logged in. If they're not, am I supposed to use this?:</p>
  
  <pre><code> Membership.ValidateUser("someguy", "somepass");
  </code></pre>
  
  <p>I get an error about making a secure connection to the server if I run the above. I have this as my provider:</p>
  
  <pre><code>&lt;membership defaultProvider="AspNetActiveDirectoryMembershipProvider"&gt;
    &lt;providers&gt;
      &lt;clear /&gt;
      &lt;add name="AspNetActiveDirectoryMembershipProvider" 
           type="System.Web.Security.ActiveDirectoryMembershipProvider"
           connectionStringName="ADConnect" attributeMapUsername="sAMAccountName"
           /&gt;
  
    &lt;/providers&gt;
  &lt;/membership&gt;
  </code></pre>