[horde] Re: Hook question
AJ
aj at mindcrash.com
Sun Mar 6 16:34:12 PST 2005
Thanks! I did manage to get the from_addr hook to work, but the fullname hook
is giving me problems. My hooks are below.
For the fullname hook, I am trying to return the value of displayName in ldap.
I also had to replace uid= w/ cn= for some reason to get from_addr to work.
Can you see what I'm doing wrong w/ fullname?
Thanks.
AJ
if (!function_exists('_prefs_hook_from_addr')) {
function _prefs_hook_from_addr($user = null)
{
$domain_name = 'mindcrash.com';
$ldapServer = 'localhost';
$ldapPort = '389';
$searchBase = 'ou=mindcrash,ou=users,dc=mindcrash,dc=com';
$ds = @ldap_connect($ldapServer, $ldapPort);
if (is_null($user)) {
$user = Auth::getAuth();
}
$uid = Auth::getBareAuth();
$binddn = 'cn=' . $uid . ',' . $searchBase;
$bindpw = Auth::getCredential('password');
if (@ldap_bind($ds, $binddn, $bindpw)) {
$searchResult = @ldap_search($ds, $searchBase, 'cn=' . $uid);
}
$information = @ldap_get_entries($ds, $searchResult);
// derive the email address if possible
if ($information[0]['mail'][0] != '') {
$emailname = $information[0]['mail'][0];
} else {
$emailname = $information[0]['cn'][0] . '@' . $domain_name;
}
ldap_close($ds);
return $emailname;
}
}
if (!function_exists('_prefs_hook_fullname')) {
function _prefs_hook_fullname($user = null)
{
$ldapServer = 'localhost';
$ldapPort = '389';
$searchBase = 'ou=mindcrash,ou=users,dc=mindcrash,dc=com';
$ds = @ldap_connect($ldapServer, $ldapPort);
if (is_null($user)) {
$user = Auth::getAuth();
}
$uid = Auth::getBareAuth();
$binddn = 'cn=' . $uid . ',' . $searchBase;
$bindpw = Auth::getCredential('password');
if (@ldap_bind($ds, $binddn, $bindpw)) {
$searchResult = @ldap_search($ds, $searchBase, 'cn=' . $uid);
}
$information = @ldap_get_entries($ds, $searchResult);
// derive the email address if possible
if ($information[0]['displayName'][0] != '') {
$name = $information[0]['displayName'][0];
} else {
$name = $information[0]['gecos'][0];
}
// $test = ($information[0]['gecos'][0]);
ldap_close($ds);
return $name;
}
}
Quoting Craig White <craigwhite at azapple.com>:
> On Sun, 2005-03-06 at 17:28 -0500, AJ wrote:
>> Hi,
>> I am trying to enable the fullname and from_addr hooks from the wiki.
>> I copied everything over, and made sure that hook => true in
>> horde/config/prefs.php, but the hooks just never fire. I also
>> cleared out the
>> prefs, so that it emulates the first login. Does anyone know why
>> these hooks
>> are not firing? Any help w/ this would be great. I am using the
>> LDAP examples
>> from the wiki.
> ----
> 'hook' => 'true',
>
> ^^^^^^^^^^^^^^^^ I think this is literally how it must be.
>
> You may be able to omit the single quotes around the word true
>
> You would have to change $searchBase to the ou which contains your user
> entries...
>
> as long as you can do this...
>
> ldapsearch -x -h localhost -D "uid=YOUR_USER_NAME,$searchBase" -b
> "$searchbase" -W "(uid=YOUR_USER_NAME)"
>
> it will work...
>
> lastly, I did modify my setup some since the wiki (I should change
> that). The difference should be obvious.
>
> if (!function_exists('_prefs_hook_from_addr')) {
>
> function _prefs_hook_from_addr($user = null)
> {
>
> $domain_name = 'azapple.com';
> $ldapServer = 'localhost';
> $ldapPort = '389';
> $searchBase = 'ou=People,dc=azapple,dc=com';
> $ds = @ldap_connect($ldapServer, $ldapPort);
>
> if (is_null($user)) {
> $user = Auth::getAuth();
> }
>
> $uid = Auth::getBareAuth();
> $binddn = 'uid=' . $uid . ',' . $searchBase;
> $bindpw = Auth::getCredential('password');
>
> if (@ldap_bind($ds, $binddn, $bindpw)) {
> $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $uid);
> }
>
> $information = @ldap_get_entries($ds, $searchResult);
>
> // derive the email address if possible
> if ($information[0]['mail'][0] != '') {
> $emailname = $information[0]['mail'][0];
> } else {
> $emailname = $information[0]['uid'][0] . '@' . $domain_name;
> }
>
> ldap_close($ds);
>
> return $emailname;
> }
> }
>
>
> Craig
>
>
>
> --
> Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: horde-unsubscribe at lists.horde.org
>
More information about the horde
mailing list