/**
* Retrieves user preferences from the backend.
*
* @throws Sam_Exception
*/
public function retrieve()
{
$attrib = Horde_String::lower($this->_params['attribute']);
try {
$search = $this->_ldap->search($this->_params['basedn'], Horde_Ldap_Filter::create($this->_params['uid'], 'equals', $this->_user), array('attributes' => array($attrib)));
$entry = $search->shiftEntry();
if (!$entry) {
throw new Sam_Exception(sprintf('LDAP user "%s" not found.', $this->_user));
}
foreach ($entry->getValue($attrib, 'all') as $attribute) {
list($a, $v) = explode(' ', $attribute);
$ra = $this->_mapOptionToAttribute($a);
if (is_numeric($v)) {
if (strstr($v, '.')) {
$newoptions[$ra][] = (double) $v;
} else {
$newoptions[$ra][] = (int) $v;
}
} else {
$newoptions[$ra][] = $v;
}
}
} catch (Horde_Ldap_Exception $e) {
throw new Sam_Exception($e);
}
/* Go through new options and pull single values out of their
* arrays. */
foreach ($newoptions as $k => $v) {
if (count($v) > 1) {
$this->_options[$k] = $v;
} else {
$this->_options[$k] = $v[0];
}
}
}