[owncloud-devel] Get current user from outside

George W Langham georgelangham1990 at gmail.com
Thu Jun 23 15:21:29 GMT 2016


yes.

On Wed, May 25, 2016 at 7:43 AM, <sign_in at die-herzogs.com> wrote:

> Hi all!
>
> I'm wondering if / how I can get the logged in user from another subdomain?
>
>    - oC is running on 'sub.myDomain.tld'
>    - My script is running on 'another.sub.myDomain.tld'
>
> I tried
>
> chdir('../path/to/oC/');    // it didn't work to require_once() the
> following files directly due to an autoloader exception so I just changed
> the current dir
> require_once 'lib/base.php';
> require_once 'lib/public/user.php';
>
> if( \OCP\User::isLoggedIn())
> {
>     $user->username = \OC::$server->getUserSession();
> }
> else
> {
>     $user->username = 'NO_USER';
> }
>
> $user->username = \OC::$server->getUserSession()->getUser()->getUID() ;
>
> var_dump($user->username);  // string(7) "NO_USER"
>
> I also added the used subdomain as trusted domain in /config/config.php.
> I guess I can't just include /lib/base.php, can I? It works if I try this
> with a file within my oC directory.
>
>
>
> Many thanks in advance!
>
> Stefan
>
> _______________________________________________
> Devel mailing list
> Devel at owncloud.org
> http://mailman.owncloud.org/mailman/listinfo/devel
>
>


-- 
Regards,

George William Langham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20160623/3815b797/attachment.html>


More information about the Devel mailing list