亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

CentOS 7 上的 PHP:LDAP 無法綁定到服務器

CentOS 7 上的 PHP:LDAP 無法綁定到服務器

PHP
慕尼黑8549860 2022-10-09 20:09:36
我有以下代碼    public function openConnection()    {        $this->ldapServerHandle = ldap_connect(ConfigH::getConfig()->ldap->host);        $bindDN = ConfigH::getConfig()->ldap->serviceAccount->bindDN;        if ($this->ldapServerHandle) {            $this->ldapBindHandle = ldap_bind(                $this->ldapServerHandle,                $bindDN,                ConfigH::getConfig()->ldap->serviceAccount->password            );            if (!$this->ldapBindHandle) {                $errorMsg = "LDAP::__construct(): Could not bind the service account ".$bindDN;                LoggerH::emergency($errorMsg);                throw new LDAPException($errorMsg);            }        } else {            $errorMsg = "LDAP::__construct(): Could not connect to the LDAP server ".ConfigH::getConfig()->ldap->host;            LoggerH::emergency($errorMsg);            throw new LDAPException($errorMsg);        }    }問題從今天早上開始,我遇到了這個錯誤,讓我很頭疼:Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server [...]在 Windows 上一切正常,當我在 CentOS 生產服務器上執行代碼時,它停止工作。我已經檢查過的OpenLDAP 已安裝并啟用LDAP 服務器可從 CentOS 服務器訪問(Kerberos 在同一臺機器上沒有遇到任何問題)我已經嘗試過的重新安裝了php-ldap擴展檢查憑據和地址一百萬次附加信息ConfigH::getConfig()->ldap->host 返回類似“adserver.ourcompany.com”的內容,這是我們的 LDAP 服務器的地址ConfigH::getConfig()->ldap->serviceAccount->bindDN 返回一個有效的綁定 DNConfigH::getConfig()->ldap->serviceAccount->password 返回服務賬號的密碼
查看完整描述

1 回答

?
夢里花落0921

TA貢獻1772條經驗 獲得超6個贊

解決方案

使用 CentOS 的人獲得 SELinux,是的。
在深入挖掘 Google(例如結果的第 4 頁)和 Stackoverflow 之后,我發現問題是由 SELinux 限制httpd通過某些端口進行通信,盡管防火墻被配置為允許它,包括 LDAP 端口。

要允許httpd通過這些端口進行通信,請運行以下命令

setsebool -P httpd_can_network_connect 1

(這里的原始解決方案(WhoIsRich 的回答))


查看完整回答
反對 回復 2022-10-09
  • 1 回答
  • 0 關注
  • 152 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號