繁体   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