【问题标题】:Issues binding to Active Directory using PHP on Apache在 Apache 上使用 PHP 绑定到 Active Directory 的问题
【发布时间】:2012-09-05 14:14:48
【问题描述】:

我在 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

【问题讨论】:

    标签: php apache active-directory ldap


    【解决方案1】:

    我发现了问题。

    显然 SELinux 阻止了我需要连接的端口,所以我基本上只是告诉 SELinux 可以连接到该端口。现在一切都像一个魅力。以下是我允许 Apache 访问端口的方式:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-11
      • 1970-01-01
      • 2016-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      相关资源
      最近更新 更多