6.0.0-git
2021-10-28
Last Modified 2013-02-17 by Guest
<?php
class Horde_Hooks
{

public function prefs_init($pref, $value, $username, $scope_ob)
{
switch ($pref) {
case 'from_addr':
if (is_null($username)) {
return $value;
}
$searchBase = 'ou=users,dc=simonandkate,dc=lan';
$cmd = '/usr/bin/ldapsearch -ZZ -x -b ' . $searchBase . ' uid=' . escapeshellcmd($username) . ' | /bin/grep mail | /usr/bin/awk \'{print $2}\;
$mails = `$cmd`;
$mail_array = explode("\n", $mails);
$mail = $mail_array['0'];
return empty($mail)
?

: $mail;

case 'fullname':
if (is_null($username)) {
return $value;
}
$searchBase = 'ou=users,dc=simonandkate,dc=lan';
$cmd = '/usr/bin/ldapsearch -ZZ -x -b ' . $searchBase . ' uid=' . escapeshellcmd($username) . ' | /bin/grep cn: | /usr/bin/cut -c5-';
$cns = `$cmd`;
$cn_array = explode("\n", $cns);
$cn = $cn_array['0'];
return empty($cn)
? $username
: $cn;
}
}
}