簡體   English   中英

PHP ldap_bind“例外”

[英]PHP ldap_bind “exception”

這是我的代碼,並且正在正常工作。

$authenticated = ldap_bind($conn, $this->username . "@" . $servidor_dominio, $this->password);

此函數的說明指定它返回bool。 當用戶輸入錯誤的用戶名和密碼組合時,我從服務器收到錯誤消息:

Error 500. ldap_bind(): Unable to bind to server: Invalid credentials

這確實是一個PHP警告,但它停止了我的應用程序的執行。 它甚至顯示了堆棧跟蹤頁面(我正在使用Yii PHP Framework)。

我嘗試捕獲將ldap_bind()調用放入try / catch塊中的異常:

try {
    $authenticated = ldap_bind($conn, $this->username . "@" . $servidor_dominio, $this->password);
} catch (Exception $exc) {
    echo $exc->getTraceAsString();
}

它沒有捕獲任何異常,並且我仍然遇到相同的錯誤:

Error 500 ldap_bind(): Unable to bind to server: Invalid credentials

有人可以幫我弄這個嗎? 看來我的用戶經常錯過輸入他們的登錄憑據的方式;-)

只需在ldap_bind前面放置一個@符號,然后使用$ authenticated變量(如果他們正確地進行了驗證)就可以向用戶顯示。

$authenticated = @ldap_bind($conn, $this->username . "@" . $servidor_dominio, $this->password);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM