0

我有这个功能:

<?php
private function spawnAdapter($credentials) {

    //$ldapConfig = array("server1" => array(
    //  "host" => "172.16.100.32",
    //  "useStartTls" => 1,
    //  "accountDomainName" => "schoolxp",
    //  "accountDomainNameShort" => "schoolxp",
    //  "accountCanonicalForm" => 3,
    //  "baseDn" => "DC=schoolxp",
    //));

    // We must retrieve the LDAP servers from the conf
    $ldapConfig = $this->_config->ldap->toArray();

    // Remove the log path, otherwise the adapter will think this is
    // one of our servers and fail.
    unset($ldapConfig['log']);   

    $adapter = new Zend_Auth_Adapter_Ldap(
        $ldapConfig, 
        $credentials['username'], 
        $credentials['password']
    );

    return $adapter;

}
?>

还有一个如下所示的ini配置文件:

[production]
ldap.log.enabled = 1
ldap.log.path = "../logs/ldap.log"
; Place your Active Directory Server Settings Here.
ldap.server1.host = "172.16.100.32"
ldap.server1.useStartTls = 1
ldap.server1.accountDomainName = "schoolxp"
ldap.server1.accountDomainNameShort = "schoolxp"
ldap.server1.accountCanonicalForm = 3
ldap.server1.baseDn = "DC=schoolxp"

当 PHP 数组用于 Auth_Adapter 时,代码工作正常,但是如果我切换到使用 INI 配置,它会失败并出现未知错误。

我在 INI 文件数组和 PHP 数组上都运行了 print_f,它们是相同的,但是 LDAP 适配器仍然在日志文件中引发异常。

有趣的是,日志中的连接字符串对于 INI 文件和数组是相同的。对于那些感兴趣的人,这里是日志文件: http: //pastebin.com/V5Nyz9FK

任何有关情况的信息将不胜感激

4

1 回答 1

0

在我看来,LDAP 适配器试图连接到错误的端口 (0)。请尝试使用以下方法指定它:

ldap.server1.port = 389

或您使用的任何端口。

于 2012-04-03T20:17:16.917 回答