0
votes

I have browsed through many questions about this and have exhausted my options, so here it goes. I have a Windows 2008R2 domain controller. I am using PHP to connect to it from a different server, same domain, using LDAP. (Also Win2008R2, IIS7.5) I have ensured the following:

  • Certificate for the domain controller has been imported to the trusted root authority store on the PHP machine
  • I have used ldp.exe on the PHP machine and can connect AND bind over LDAPS using the name of the DC and port 636
  • My user credentials are correct
  • I can connect using LDAP, port 389 in PHP just fine

Here is my code:

putenv('LDAPTLS_REQCERT=never');

    $host = "ldaps://mydc.thing.com:636";
    $dn = "Admin User";
    $dnp = "adminPaSwOrD";


    $base = "DC=thing,DC=com";
    $scope = "sub";

    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

    $ds = ldap_connect($host);

    $r=ldap_bind($ds, $dn, $dnp);  

The error message is always:

PHP Warning:  ldap_sasl_bind() [<a href='function.ldap-sasl-bind'>function.ldap-sasl-bind</a>]: Unable to bind to server: Can't contact LDAP server in ...

Relevant PHP info:

#Version 5.3.8
#cURL: 7.22.0, SSL:yes, dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
#LDAP: enabled, SASL: enabled, OpenLdap v.20319

I have scoured Goggle and tried quite a few things myself. The wierd part is that an LDAP client on the PHP machine can connect and bind to the DC, just not in PHP. I've also tried PHP from CLI (to cut IIS out of the mix) and it returns the same error.

Any help would be greatly appreciated.

SG

1
Have you tried the suggestions mentioned in stackoverflow.com/questions/5258556/… ? - Yuvika
@YSU - yes, I've put putenv('LDAPTLS_REQCERT=never'); at the top of the script as well as putting an ldap.conf at the root(c:) as well as in the suggested folder, c:\openldap\sysconf\, all to no avail. Perhaps I should upgrade PHP? I think I will try that. My certificates are valid and there is no SSL error on the DC side when I attempt to connect. - S.Giacinto

1 Answers

0
votes

I upgraded PHP to 5.6 and the problem went away. I do not know why. To answer my own question "What am I missing to make this work?" - I was missing the correct PHP version I guess.