I setup a CentOS 7 vm webserver with the LAMP stack. Over the last few days I have been trying to get an LDAPS connection working to my Windows Server 2008 R2 Domain Controller.
I have been able to connect to my DC with: ldapsearch -H "ldaps://server.ad.com" -D "domain\user-name" -W
for a couple days. I am also able to use the openssl s_client -connect server.ad.com -prexit
command to verify the SSL cert (as I am using a self-signed cert).
However, whenever I browse to my PHP webpage in the /var/www/html/test/index.php I always receive "Can't contact LDAP server" errors when trying to ldap_bind()
. Yesterday I tried running the PHP file from command line: php /var/www/html/test/index.php
and found that my PHP ldap_bind() works every time when using the command line.
Searching on the internet, I have found that often the PHP-CLI and PHP Apache will use different php.ini files, but running the php --ini
command only shows me a single php.ini file located in /etc/php.ini.
I am trying to figure out why PHP executes correctly from the command line but not when browsed to/run through Apache. Any info/ideas to help solve this would be greatly appreciated, thank-you!
ldapsearch
and/oropenssl sclient
from the command line would be a good analog for what happens in PHP, but I could be wrong.. In any event, it might have something to do with the user executing the code (you vs <InsertWebServerUserHere>). Is SELinux enabled?ldap_bind()
only throwing a 'Can't contact LDAP server' error? What aboutldap_connect()
?