LDAP与PHP CLI配合使用,但不能通过apache配合使用

编程入门 行业动态 更新时间:2024-10-28 18:24:45
本文介绍了LDAP与PHP CLI配合使用,但不能通过apache配合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从Fedora框中针对Windows 2008 Server通过LDAP进行身份验证.

I'm trying to authenticate over LDAP against a Windows 2008 Server from a Fedora box.

以下代码可从命令行运行(打印成功"):

The following code works from the command line (prints "Success"):

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服务器"

...pulling the same file via Apache/mod_php prints "Can't contact LDAP server"

我已经看到很多关于此类问题的报告,但是没有有关如何解决该问题的有用信息.

I've seen a lot of reports of issues like this, but no useful information on how to resolve it.

推荐答案

我在centos6上解决了这个确切的问题很长时间了. php.ini的区别似乎是检查的好地方,但并没有给我答案.事实证明,这与SELinux有关.

I just fought this exact problem for a long time on centos6. The php.ini difference seem like a good place to check, but it didn't give me the answer. It turns out this was related to 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中的布尔值,可以使用以下命令进行调整.

You'll note, that in my case, httpd_can_network_connect was set to off. This is a boolean in SELinux and can be adjusted with the following command.

$ setsebool -P httpd_can_network_connect on

您可以在 wiki.centos/TipsAndTricks/SelinuxBooleans 上了解更多信息.以apache和ldap为例.希望对您有帮助!

You can read more about this at wiki.centos/TipsAndTricks/SelinuxBooleans which explicitly uses the case of apache and ldap as an example. Hope it helps!

更多推荐

LDAP与PHP CLI配合使用,但不能通过apache配合使用

本文发布于:2023-11-24 03:06:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623748.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PHP   LDAP   apache   CLI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!