I am trying to create a connection from php to an active directory server over ldaps. I am able to make a connection to the server if I just use ldap to connect but it isn't a secure connection. When I point php to the secure connection, it wont connect. A co-worker has given me his python code that he is using for the same connection but I am running into a problem trying to implement it in php. Here is my php code:
$connection = ldap_connect($this->ldapserver);
$adminBind = false;
if (ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3))
if (ldap_set_option($connection, LDAP_OPT_REFERRALS, 0))
if(ldap_set_option($connection, LDAP_OPT_X_TLS_REQUIRE_CERT, 0))
$adminBind = ldap_bind($connection, $this->ldapadmindn, $this->ldapadminpw);
if(!$adminBind)
return false; //server down or admin account unavailable
And here is part of the python he sent me ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
The problem comes from the line ldap_set_option($connection, LDAP_OPT_X_TLS_REQUIRE_CERT, 0)
. I am getting a Use of undefined constant LDAP_OPT_X_TLS_REQUIRE_CERT
error when I try to run this section. According to the php page for set option, this is one of the available options. Does anyone know how to get this option to work?
One answer that I have seen is to write "TLS_REQCERT never" in the ldap.conf file. I am hoping for this one connection to ignore the certificate because the web server regularly connects to another active directory and I need that to use the certificate.
Thanks for the help.