[horde] Fwd: LDAP configuration and hooks
David Wells - Alfavinil S.A.
dwells at alfavinil.com
Fri Nov 29 20:31:51 UTC 2019
Thanks for your reply.
I moved the file from hooks.local.php to hooks.php and I still get the
error stating horde is trying to connect to localhost:389 instead of the
host configured in config.php.
El 29/11/2019 a las 16:54, Arjen de Korte escribió:
> Citeren "David Wells - Alfavinil S.A." <dwells at alfavinil.com>:
>
>> Hi again!
>>
>> I discovered that when I execute in the PHP Shell just the line "$ldap =
>> $GLOBALS['injector']->getInstance('Horde_Ldap');" I already get the
>> error "exception 'Horde_Ldap_Exception' with message 'Could not connect
>> to localhost:389'"
>>
>>
>> -------- Mensaje reenviado --------
>> Asunto: [horde] LDAP configuration and hooks
>> Fecha: Thu, 28 Nov 2019 18:12:41 -0300
>> De: David Wells <dwells at alfavinil.com>
>> Para: horde at lists.horde.org
>>
>>
>>
>> Hi!
>>
>>
>> I have configured the LDAP settings in horde as follow
>>
>>> $conf['ldap']['hostspec'] = array('dc1.fliawells.com.ar');
>>> $conf['ldap']['port'] = 3268;
>>> $conf['ldap']['tls'] = true;
>>> $conf['ldap']['timeout'] = 5;
>>> $conf['ldap']['version'] = 3;
>>> $conf['ldap']['user']['basedn'] = 'DC=fliawells,DC=com,DC=ar';
>>> $conf['ldap']['user']['uid'] = 'userPrincipalName';
>>> $conf['ldap']['user']['objectclass'] = array('*');
>>> $conf['ldap']['user']['filter_type'] = 'objectclass';
>>> $conf['ldap']['bindas'] = 'user';
>>> $conf['ldap']['useldap'] = true;
>>
>> When I modify the hooks.local.php file so that it reads
>
> Horde doesn't use a 'hooks.local.php' file anywhere. The distributed
> version is called 'hooks.php.dist' and as far as I remember there is a
> 'hooks.php' in the webmail package. Chances are here is a 'hooks.php'
> file alongside your 'hooks.local.php' and it is that one that is
> actually used. Try renaming this 'hooks.local.php' file to 'hooks.php'
> and check again.
>
>>
>>> <?php
>>> class Horde_Hooks
>>> {
>>> public function prefs_init($pref, $value, $username, $scope_ob)
>>> {
>>> switch ($pref) {
>>> case 'from_addr':
>>>
>>> if (is_null($username)) {
>>> return $value;
>>> }
>>>
>>> $ldap = $GLOBALS['injector']->getInstance('Horde_Ldap');
>>> try {
>>> $result = $ldap->search(
>>> $GLOBALS['conf']['ldap']['user']['basedn'],
>>> Horde_Ldap_Filter::create('userPrincipalName', 'equals', $username),
>>> array('attributes' => array('mail'))
>>> );
>>> if ($result->count()) {
>>> $entry = $result->shiftEntry();
>>> return $entry->getValue('mail', 'single');
>>> }
>>> } catch (Horde_Ldap_Exception $e) {
>>> }
>>>
>>> return $value;
>>>
>>>
>>> case 'fullname':
>>> if (is_null($username)) {
>>> return $value;
>>> }
>>>
>>> $ldap = $GLOBALS['injector']->getInstance('Horde_Ldap');
>>> try {
>>> $result = $ldap->search(
>>> $GLOBALS['conf']['ldap']['user']['basedn'],
>>> Horde_Ldap_Filter::create('userPrincipalName', 'equals', $username),
>>> array('attributes' => array('cn', 'cn;lang-es'))
>>> );
>>> if ($result->count()) {
>>> $entry = $result->shiftEntry();
>>> return $entry->getValue('cn;lang-es', 'single')
>>> ?: $entry->getValue('cn', 'single');
>>> }
>>> } catch (Horde_Ldap_Exception $e) {
>>> }
>>>
>>> return $username;
>>> }
>>> }
>>> }
>>
>> and enable these hooks by modifying the prefs.local.php file so that it
>> reads
>>
>>> <?php
>>> $_prefs['from_addr']['hook'] = true;
>>> $_prefs['fullname']['hook'] = true;
>>
>> I get an error that says
>>
>>>
>>> Could not connect to localhost:389
>>>
>> When I comment the prefs.local.php file and access horde I run the
>> following piece of code in the PHP Shell (under the horde context
>>
>>> |$ldap| |=
>>> ||$GLOBALS||[||'injector'||]->getInstance(||'Horde_Ldap'||);|
>>> |||try| |{|
>>> |||$result| |= ||$ldap||->search(|
>>> |||$GLOBALS||[||'conf'||][||'ldap'||][||'user'||][||'basedn'||],|
>>> |||Horde_Ldap_Filter::create(||'userPrincipalName'||, ||'equals'||,
>>> ||'dwells at fliawells.com.ar'||), ||array||(||'attributes'| |=>
>>> ||array||(||'mail'||)));|
>>> |||if| |(||$result||->||count||()) {|
>>> |||$entry| |= ||$result||->shiftEntry();|
>>> |||return| |$entry||->getValue(||'mail'||, ||'single'||);|
>>> |||}|
>>> |||} ||catch| |(Horde_Ldap_Exception ||$e||) {|
>>> |||}|
>>> |||return| |$value||;|
>> I get the following result
>>
>>> exception 'Horde_Ldap_Exception' with message 'Could not connect to
>>> localhost:389' in /usr/lib64/php/Horde/Ldap.php:321
>>> Stack trace:
>>> #0 /usr/lib64/php/Horde/Ldap.php(225): Horde_Ldap->_connect()
>>> #1 /usr/lib64/php/Horde/Ldap.php(137): Horde_Ldap->bind()
>>> #2 [internal function]: Horde_Ldap->__construct(Array)
>>> #3 /usr/lib64/php/Horde/Injector/Binder/Implementation.php(88):
>>> ReflectionClass->newInstanceArgs(Array)
>>> #4 /usr/lib64/php/Horde/Injector/Binder/Implementation.php(70):
>>> Horde_Injector_Binder_Implementation->_getInstance(Object(Horde_Injector),
>>> Object(ReflectionClass))
>>> #5 /usr/lib64/php/Horde/Injector/Binder/AnnotatedSetters.php(78):
>>> Horde_Injector_Binder_Implementation->create(Object(Horde_Injector))
>>> #6 /usr/lib64/php/Horde/Injector.php(238):
>>> Horde_Injector_Binder_AnnotatedSetters->create(Object(Horde_Injector))
>>> #7 /usr/lib64/php/Horde/Injector.php(272):
>>> Horde_Injector->createInstance('Horde_Ldap')
>>> #8 /var/www/horde/admin/phpshell.php(66) : eval()'d code(1):
>>> Horde_Injector->getInstance('Horde_Ldap')
>>> #9 /var/www/horde/admin/phpshell.php(66): eval()
>>> #10 {main}
>>
>> From what I can tell the library is trying to connect lo localhost:389
>> even though the settings state that it should be connecting to
>> dc1.fliawells.com.ar:3268. What could I be missing here?
>>
>>
>> Thank you very much in advance!
>>
>> Best regards,
>>
>> David Wells.
>>
>>
>>
>> --
>> Horde mailing list
>> Frequently Asked Questions: http://horde.org/faq/
>> To unsubscribe, mail: horde-unsubscribe at lists.horde.org
>
>
>
More information about the horde
mailing list