簡體   English   中英

在Apache上使用PHP綁定到Active Directory時出現問題

[英]Issues binding to Active Directory using PHP on Apache

我在apache服務器上有一個PHP腳本,每次嘗試運行它時,它都會告訴我:

unable to bind to the AD

它連接正常。 我將其從apache服務器上取下來,並從我的機器上本地運行,它能夠很好地進行綁定。 我假設我的apache配置有問題。

我正在使用adLDAP API,這是我嘗試運行的以下腳本。 基本上,這是一項測試,確定我是否能夠成功綁定並檢查輸入的憑據是否在Active Directory中。

$username = $_POST["username"];
$password = $_POST["password"];
$formage =  $_POST["formage"];

if ($_POST["oldform"]) { //prevent null bind

    if ($username != NULL && $password != NULL){
        //include the class and create a connection
        include (dirname(__FILE__) . "/../src/adLDAP.php");
        try {
            $adldap = new adLDAP();
        }
        catch (adLDAPException $e) {
            echo $e;
            exit();
        }

        //authenticate the user
        if ($adldap->authenticate($username, $password)){
            //establish your session and redirect
            session_start();
            $_SESSION["username"] = $username;
            $_SESSION["userinfo"] = $adldap->user()->info($username);
            $redir = "Location: https://" . $_SERVER['HTTP_HOST'] .
                dirname($_SERVER['PHP_SELF']) . "/menu.php";
            header($redir);
            exit;
        }
    }
    $failed = 1;
}

為什么會出現此錯誤: unable to bind to the AD

我發現了問題。

顯然SELinux阻塞了我需要連接的端口,因此我基本上只是告訴SELinux可以連接到該端口。 現在,一切都像魅力。 這是我允許Apache訪問端口的方式:

grep httpd /var/log/audit/audit.log | audit2allow -M mypol
semodule -i mypol.pp

暫無
暫無

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

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