title: LDAP_BIND Can't contact LDAP server
body: <p>I have a question for you.</p>
  
  <p>My goal is to bind a ldap server with php.</p>
  
  <ul>
  <li>When I try with a terminal ( bash ) I use:</li>
  </ul>
  
  <blockquote>
    <p>ldapsearch -H ldaps://[server]:[port] -D [dn] -W</p>
  </blockquote>
  
  <p>It works well.</p>
  
  <ul>
  <li>When I try with a php script</li>
  </ul>
  
  <blockquote>
    <p>$server = array("ldaps://[server]", "[port]");</p>
    
    <p>$userdn = "[dn]";</p>
    
    <p>$userpw = "[pw]";</p>
    
    <p>$ds = ldap_connect($server[0], $server[1]) or die("ldap server offline");</p>
    
    <p>ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);</p>
    
    <p>ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);</p>
    
    <p>ldap_bind($ds, $userdn, $userpw);</p>
  </blockquote>
  
  <p>Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server</p>
  
  <p>I don't understand my mistake. I've search all night long on google.</p>
  
  <p>Q/A</p>
  
  <blockquote>
    <p>_ I use mamp ( apache )</p>
    
    <p>_ Ldap server pings good, and works with bash.</p>
    
    <p>_ I use a firewall, but it doesnt work without too.</p>
    
    <p>_ all [var] are ok, because in bash it works.</p>
  </blockquote>