title: AD authentication in php login page
body: <p>I want to create AD Authentication in php login page  which will take
  my organization users login id and password and let them login to the
  page i got below code from stackoverflow itself i have   few doubts in
  place of ldapserver name  what shall i put and what is OU AND DC
  Front-end for AD Authentication in php  login page</p>
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;style&gt;
              body
              {
                  text-align:center;
              }
              form
              {
                  margin: 0 auto; width: 500px;
              }
              input
              {
                  padding: 10px; font-zie:20;
              }
      &lt;/head&gt;
          &lt;/style&gt;
      &lt;body&gt;
      &lt;h1&gt; authentication with AD &lt;/h1&gt;
      &lt;form action=&quot;Auth.php&quot; method=&quot;post&quot;&gt;
          &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;&lt;br&gt;
          &lt;input type=&quot;password&quot; name=&quot;password&quot; /&gt;&lt;br&gt;
          &lt;input type=&quot;submit&quot; value=&quot;Login&quot; /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  
  MYAuthpage.php
  &lt;?php
      $ldaprdn  = $_POST[&quot;username&quot;];
      $ldappass = $_POST[&quot;password&quot;];
      $ldapconn = ldap_connect(&quot;ldap server name&quot;) or die(&quot;Could not connect to LDAP server.&quot;);
  
  if ($ldapconn) 
  {
      $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
      if ($ldapbind) 
      {
          echo &quot;LDAP bind successful...&quot;;
      }
      else 
      {
          echo &quot;LDAP bind failed...&quot;;
      }
  }
  $Result = ldap_search($ldapconn, &quot;OU=IT,DC=&quot;Domain&quot;,DC=corp&quot;, &quot;(samaccountname=$ldaprdn)&quot;, array(&quot;dn&quot;));
  $data = ldap_get_entries($ldapconn, $Result);
  print_r($data);
  ?&gt;
  </code></pre>