[horde] Hook Question
Amith Varghese
amith at xalan.com
Tue May 10 08:52:12 PDT 2005
Quoting AJ <aj at mindcrash.com>:
> Ben,
> I think it is using ldap_search.. here is the hook I am using.
> Any ideas?
>
Here is the hook that I use and that work against HEAD (from about 2
weeks ago)
if (!function_exists('_prefs_hook_fullname')) {
function _prefs_hook_fullname($user = null)
{
$ldapServer = 'localhost';
$ldapPort = '389';
$vdomain = $_SERVER['HTTP_HOST'];
$vdomain = preg_replace('|^mail\.|i', '', $vdomain);
$vdomain = String::lower($vdomain);
$domainparts = split("\.",$vdomain);
$searchBase = 'ou=People,o=' . $domainparts[0] . ',o=' .
$domainparts[1] . ',c=US';
$ldapcharset = 'utf-8';
$outputcharset = NLS::getCharset();
$ds = @ldap_connect($ldapServer, $ldapPort);
// Find the user
if (empty($user)) {
$user = Auth::getAuth();
if (empty($user)) {
$user = Util::getFormData('imapuser') . '@' .
Util::getFormData('maildomain');
}
}
// get the password
$password = Auth::getCredential('password');
if (empty($password)) {
$password = Util::getFormData('pass');
}
if ($ds) {
Horde::logMessage($user . ',' . $searchBase, __FILE__,
__LINE__, PEAR_LOG_DEBUG);
$ldapbind = ldap_bind($ds, 'uid=' . $user . ',' .
$searchBase, $password);
}
$searchResult = @ldap_search($ds, $searchBase, 'uid=' . $user);
$information = @ldap_get_entries($ds, $searchResult);
$name = $user;
if ($information['count'] != 0 && $information[0]['cn'][0] != '') {
$name = $information[0]['cn'][0];
}
ldap_close($ds);
$name = String::convertCharset($name, $ldapcharset, $outputcharset);
return $name;
}
}
More information about the horde
mailing list