我正在尝试从Fedora框中针对Windows 2008 Server对LDAP进行身份验证.
以下代码从命令行工作(打印"成功"):
if($ldap = ldap_connect('10.0.0.101')) { ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $bind = ldap_bind($ldap,'administrator@domain.tld','XXXXXXX'); print ldap_error($ldap); }
...通过Apache/mod_php拉相同的文件打印"无法联系LDAP服务器"
我已经看过很多关于这类问题的报告,但没有关于如何解决它的有用信息.
我刚刚在centos6上与这个问题进行了长时间的斗争.php.ini差异似乎是一个值得检查的好地方,但它没有给我答案.事实证明这与SELinux有关.
$ getsebool -a | grep httpd allow_httpd_anon_write --> off allow_httpd_mod_auth_ntlm_winbind --> off allow_httpd_mod_auth_pam --> off allow_httpd_sys_script_anon_write --> off httpd_builtin_scripting --> on httpd_can_check_spam --> off httpd_can_network_connect --> off httpd_can_network_connect_cobbler --> off httpd_can_network_connect_db --> on httpd_can_network_memcache --> on httpd_can_network_relay --> off httpd_can_sendmail --> off httpd_dbus_avahi --> on httpd_enable_cgi --> on httpd_enable_ftp_server --> off httpd_enable_homedirs --> off httpd_execmem --> off httpd_manage_ipa --> off httpd_read_user_content --> off httpd_run_stickshift --> off httpd_setrlimit --> off httpd_ssi_exec --> off httpd_tmp_exec --> off httpd_tty_comm --> on httpd_unified --> on httpd_use_cifs --> off httpd_use_gpg --> off httpd_use_nfs --> off httpd_use_openstack --> off httpd_verify_dns --> off
你会注意到,在我的情况下,httpd_can_network_connect被设置为关闭.这是SELinux中的布尔值,可以使用以下命令进行调整.
$ setsebool -P httpd_can_network_connect on
您可以在http://wiki.centos.org/TipsAndTricks/SelinuxBooleans上阅读更多相关内容,其中明确使用apache和ldap的示例作为示例.希望能帮助到你!