title: can not bind to the LDAP directory with secure connection with php
body: <p><strong>Installation Information:</strong><br/>
  I have two Windows servers. One (Windows Server 2008 R2) is a domain controller (DC) with Active Directory (AD).Its name is s1.xyz.com. The second (Windows Server 2003 R2) server is running IIS, PHP.SSL certificate is installed on second server.<br/></p>
  
  <p>I have installed Active Directory Certificate Services on DC server to act as a Certificate Authority (CA) and also enable LDAP over SSL(LDAPS) using below link:<br/>
  <a href="http://www.christowles.com/2010/11/enable-ldap-over-ssl-ldaps-on-windows.html" rel="nofollow">http://www.christowles.com/2010/11/enable-ldap-over-ssl-ldaps-on-windows.html</a> </p>
  
  <p><strong>What is the problem:</strong><br>
  Actually, I want to set password for AD users so my requirement is secure connection(LDAPS) to do so.
  I can successfully connect to the DC on unsecured port (389) and access AD data but
  I can not bind user on secure connection (on port 636) using PHP ldap_bind() function.
  When i run the script it gives "ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server" error.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$ip="xxx.xxx.xxx.xx";
  
  $ldaps_url="ldaps://s1.xyz.com:636/";
  
  $ldap_url="s1.xyz.com";
  
  $ldapUsername ="Administrator@xyz.com";
  
  $ldapPassword="x1y1z1";
  
  $ds=ldap_connect($ldaps_url);
  
  //$ds=ldap_connect($ip,636);
  
  ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION,3);
  
  ldap_set_option($ds, LDAP_OPT_REFERRALS,0);
  
  $bth=ldap_bind($ds, $ldapUsername, $ldapPassword);
  
  ldap_unbind($ds);
  
  $ds="";
  </code></pre>