I have this function:
<?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;
}
?>
and also a ini config file that looks like the following:
[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"
The code works fine when the PHP Array is used for the Auth_Adapter, however if I switch to use the INI config it fails with an unknown error.
I have ran print_f on both the INI file array and the PHP Array and they are identical, however the LDAP adapter still throws an exception in the log file.
Interestingly the connection string in the log is identical for both the INI file and the array.. For those interested here is the log file: http://pastebin.com/V5Nyz9FK
Any light on the situation would be greatly appreciated
It seems to me that the LDAP Adapter tries to connect to the wrong port (0). Please try to specify it using:
ldap.server1.port = 389
or whatever port you're using.
It doesnt explain why having it set in the ini file doesnt work however, because essentially the LDAP Adapter receives exactly the same (or so I think) array regardless of which config is used, and it works when a native PHP array is used with exactly the same setting - Brad Morris 2012-04-03 23:04