[horde] LDAP Preference hooks not working
Jan Schneider
jan at horde.org
Wed Jul 2 06:44:14 UTC 2008
Zitat von Zachariah Mully <zmully at smartbrief.com>:
> Hello all-
> I recently switched the authentication on our FRAMEWORK_3 install from
> using IMAP to straight LDAP for performance reasons. This in turn
> screwed up the default identity, as this is apparently set automatically
> when auth'ed via IMAP, but not via LDAP. I am storing preferences in
> mysql, but I want to populate the users full name and email address from
> my LDAP directory.
> I found the hooks for the fullname and from_addr and tried each of the
> suggested LDAP hooks on the wiki
> (http://wiki.horde.org/CustomizingPreferences).
> When I configure these hooks, they break the login, as the first load
> of the login page attempts to auth as a NULL user, so my LDAP binddn
> ends up looking like 'uid=,ou=Users,ou=OxObjects,dc=smartbrief,dc=com'
> and the result returned is NULL, so it throws this error "Notice:
> Undefined offset: 0 in /var/www/horde3/config/hooks.php on line 163".
> This goes for any of the suggested LDAP hooks on the wiki, but in my
> instance I'm currently trying to use:
>
> if (!function_exists('_prefs_hook_fullname')) {
> function _prefs_hook_fullname($uid = null)
> {
> global $conf;
>
> if (is_null($uid)) {
> $uid = Auth::getAuth();
> }
>
> $entry="Fullname hook was called for user $uid";
> Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);
>
> $ds = @ldap_connect($conf['auth']['params']['hostspec']);
>
> @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION,
> $conf['auth']['params']['version']);
> @ldap_bind($ds, $conf['auth']['params']['binddn'],
> $conf['auth']['params']['password']);
> $searchResult = @ldap_search($ds,
> $conf['auth']['params']['basedn'], $conf['auth']['params']['uid'] .
> '=' . $uid);
>
> $information = @ldap_get_entries($ds, $searchResult);
> ldap_close($ds);
>
> $entry="From_addr result is $information[0]['cn'][0]";
> Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);
>
> return $information[0]['cn'][0];
>
> }
> }
>
>
> I don't see how no one else is having this problem, so does anyone have
> any suggestions as to how to fix this?
Don't query the ldap server if the user name is empty.
Jan.
--
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/
More information about the horde
mailing list