[horde] Individual hosts in gollem
Christopher Neuhaus
cne at ruhrverband.de
Wed May 16 12:56:06 UTC 2012
>
>> Hi Jan,
>>
>>>
>>> Zitat von Christopher Neuhaus <cne at ruhrverband.de>:
>>>
>>>> Hi List!
>>>>
>>>> I just try to get the list of servers on which the user can log in by
>>>> smb in gollem.
>>>> In horde and IMP, this is no problem, because I can use the hook to
>>>> extract the server from the mail address, I can get from yellow pages
>>>> (ypmatch).
>>>>
>>>> But how can I do this in gollem?
>>>
>>> Please use more words to describe exactly what you are trying to do,
>>> how you do that in IMP, what you tried in Gollem, and what didn't
>>> work, including examples.
>>>
>> sorry for my short expression.
>> We use this hook to get the right authentication-server for the login:
>>
>> /horde/config/hooks.php:
>> ---------------------------------
>> class Horde_Hooks
>> {
>> public function preauthenticate($userId, $credentials)
>> {
>> require dirname(__FILE__) . '/../imp/config/backends.local.php';
>> $ma = exec("/usr/bin/ypmatch $userId mail.aliases");
>> if ( strpos($ma,",")) {
>> $ma = substr($ma,0,strpos($ma,","));
>> $mserver = strtolower(substr($ma,strpos($ma,"@")+1));
>> } else {
>> $mserver = strtolower(substr($ma,strpos($ma,"@")+1));
>> }
>> foreach ( $servers as $key => $curServer ) {
>> if ( $servers[$key]['smtphost'] == $mserver ) {
>> $credentials['server'] = $key;
>> break;
>> }
>> }
>> return array('credentials' => $credentials);
>> }
>> }
>> ---------------------------------
>> Now we want to use the same serverlist from
>> '/../imp/config/backends.local.php' to choose the server for the
>> smb-authentication in gollem.
>>
>> My solution is now in /var/www/horde/gollem/config/backends.local.php
>> ---------------------------------
>> $rv_auth = $GLOBALS['registry']->getAuth('bare');
>> require dirname(__FILE__) . '/../../imp/config/backends.local.php';
>> $ma = exec("/usr/bin/ypmatch $rv_auth mail.aliases");
>>
>> if ( strpos($ma,",")) {
>> [...] see above
>>
>> $backends['smb'] = array(
>> 'disabled' => false,
>> [...]
>> 'params' => array(
>> 'hostspec' => $mserver,
>> 'port' => 139,
>> 'share' => $rv_auth,
>> [...]
>>
>>
>> ---------------------------------
>>
>> This mods are not really robust and make a bad performance on the
>> login-site.
>> I think there can be a better solution.
>
> What's not robust about them? The only issue I see with this approach,
> is that you shouldn't load IMP's backend configuration from Gollem. If
> you are only after $rv_auth, put that into a separate file that you
> load from both backend.local.php files. And you probably want to cache
> the result, so that it's only called once during the complete Horde
> session.
>
Okay, I was worried not to check some api methods or a special global
arrays which would tell me the hostspec.
So I can make it perhaps more efficient when I take the session:
$rv_aut = $GLOBALS['registry']->getAuth('bare');
require dirname(__FILE__) . '/../../imp/config/backends.local.php';
foreach ($_SESSION['imp'] as $key => $val) {
if($key == "0server_key"){
foreach ($servers as $key2 => $IMAPServer) {
if ($key2 == $val){
$rv_host = $IMAPServer['smtphost'];
break;
}
}
}else{
break;
}
}
$backends['smb'] = array(
'disabled' => false,
'name' => 'Dateiablage',
'driver' => 'smb',
'hordeauth' => true,
'params' => array(
'hostspec' => $rv_host,
'port' => 139,
'share' => $rv_aut,
[...]
Regards,
Christopher
More information about the horde
mailing list