我有这个功能:
<?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
对此情况有任何了解
答案 0 :(得分:0)
在我看来,LDAP适配器尝试连接到错误的端口(0)。 请尝试使用以下方式指定:
ldap.server1.port = 389
或您正在使用的任何端口。