How do I solve ldap_start_tls() “Unable to start TLS: Connect error” in PHP?

后端 未结 7 1239
温柔的废话
温柔的废话 2020-12-14 03:59

I\'m getting:

Warning: ldap_start_tls() [function.ldap-start-tls]: Unable to start TLS: Connect error in /var/www/X.php on line Y

7条回答
  •  别那么骄傲
    2020-12-14 04:06

    You can ignore the validity in windows by issuing

    putenv('LDAPTLS_REQCERT=never');
    

    in your php code. In *nix you need to edit your /etc/ldap.conf to contain

    TLS_REQCERT never
    

    Another thing to be aware of is that it requires version 3 (version 2 is php default):

    //$hostnameSSL example would be "ldaps://just.example.com:636" , just make sure it has ldaps://
    $con = ldap_connect($hostnameSSL);
    ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
    

    To get a better idea of what's going on, you can enable debug logging by:

    ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
    

    This can be done before the ldap_connect takes place.

提交回复
热议问题