[horde] Current logged in user

Michael Rubinsky mrubinsk at horde.org
Sat Jul 24 15:54:19 UTC 2010


Quoting Peter Øgaard Meyland <peter at meyland.dk>:

> Citat af Michael Rubinsky <mrubinsk at horde.org>:
>
>>
>> Quoting Peter Øgaard Meyland <peter at meyland.dk>:
>>
>>> Citat af Michael Rubinsky <mrubinsk at horde.org>:
>>>
>>>>
>>>>
>>>> On Jul 23, 2010, at 8:54 AM, Peter Øgaard Meyland  
>>>> <peter at meyland.dk> wrote:
>>>>
>>>>> Hi list
>>>>>
>>>>> I'm working on my own intranet with user specific settings, i.e.  
>>>>> a book database and movie database. The intranet is displayed in  
>>>>> a Horde Block on the main portal screen. I need to get the  
>>>>> current logged in Horde user, so I can display the right  
>>>>> intranet page for the user. I have the latest Horde Webmail  
>>>>> Edition and I'm working with PHP as my server side language.
>>>>>
>>>>> Can anyone show me the PHP code to get current logged in user?
>>>>
>>>>
>>>> Auth::getAuth();
>>>>
>>>>>
>>>>> TIA
>>>>> Peter
>>>>> --
>>>>> 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
>>>> --
>>>> 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
>>>>
>>>
>>> Could you please give me a code example? I've tried  
>>> Auth::getAuth() but it gave me nothing:
>>>
>>> define('HORDE_BASE',  '/var/www/html/horde');
>>> require_once(HORDE_BASE . "/lib/core.php");
>>> $current  = Auth::getAuth();
>>> echo "Horde says this user is on: <span style='color: blue;'>" .  
>>> $current . "</span><br>";
>>
>>
>> You need to bring in base.php, not core.php.
>> -- 
>> Mike
>>
>> --
>> The Horde Project (www.horde.org)
>> mrubinsk at horde.org
>>
>> "Reality is merely an illusion, albeit a very persistent one." - A. Einstein
>>
>> -- 
>> 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
>>
>>
>
> Thanks a lot, but it did not work well.
>
> My Horde are installed in /var/www/html/horde and my intranet are  
> installed in /var/www/html/intra and every time I go to getauth.php  
> in the intranet folder I get a 404 error but if I copy getauth.php  
> into the Horde root folder (/var/www/html/horde) it works,  
> strange... In my Apache error_log I get this error:
> [Fri Jul 23 22:44:43 2010] [error] [client xxx.xxx.xxx.xxx] script  
> '/var/www/html/intra/horde.php' not found or unable to stat,  
> referer: http://htpc.privat.home/horde/login.php
>
> getauth.oho looks like this:
> <?php
> define('HORDE_BASE',  '/var/www/html/horde');
> require_once(HORDE_BASE . "/lib/base.php");
> $current  = (Auth::getAuth());
> echo "Horde says this user is on: <span style='color: blue;'>" .  
> $current . "</span><br>";
> ?>
>

I think I misunderstood what you are trying to do.

If you are trying to access Horde data from within your non-horde  
application, you should be including core.php, instantiating a  
registry object, and then calling the Horde API:

<code>
define('HORDE_BASE',  '/var/www/html/horde');
require_once(HORDE_BASE . '/lib/core.php');

// Instantiate the Horde Registry
$registry = &Registry::singleton();

// Example API call, lists all available applications
$registry->call('horde/listApps', array());

// If a user *is* authenticated, this should now work also. If not,  
this will return null or false (can't remember off hand which it is).
$user = Auth::getAuth();
</code>

If, on the other hand, you are trying to access your non-horde  
application's data from within Horde, or a Horde block, then you need  
to implement some sort of callable API in your application and call it  
from Horde.

You say you are displaying this in a Horde block, so I'm not really  
sure why you need this code outside of horde. Maybe I'm still  
misunderstanding your needs?

-- 
Mike

--
The Horde Project (www.horde.org)
mrubinsk at horde.org

"Reality is merely an illusion, albeit a very persistent one." - A. Einstein



More information about the horde mailing list