DokuWiki

It's better when it's simple

User Tools

Site Tools


Sidebar

Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community


Follow us on Facebook, Twitter and other social networks.

Our Privacy Policy

auth:userinfo_debugging

I used the following hack to display the complete information on the user currently logged in. This will be displayed instead of the 'Logged in as:' field at the bottom-left of the page.

This proved very useful to me for debugging LDAP/AD group membership problems.

I modified the function tpl_userinfo() in inc/template.php.

The hack

Original:

function tpl_userinfo() {
    global $lang;
    /** @var Input $INPUT */
    global $INPUT;
 
    if($INPUT->server->str('REMOTE_USER')) {
        print $lang['loggedinas'].' '.userlink();
        return true;
    }
    return false;
}

With extra debugging information:

function tpl_userinfo() {
    global $lang;
    /** @var Input $INPUT */
    global $INPUT;
 
    if($INPUT->server->str('REMOTE_USER')) {
        print $lang['loggedinas'].' '.userlink();
        msg('Debug user info:'.print_r($USERINFO, true), -1);
        return true;
    }
    return false;
}

The nicer way

A nicer way of doing this is checking for a custom option userinfo_debug, which can now be set in conf/local.php:

function tpl_userinfo() {
    global $conf;
    global $lang;
    global $USERINFO;
    /** @var Input $INPUT */
    global $INPUT;
 
    if($INPUT->server->str('REMOTE_USER')) {
        print $lang['loggedinas'].' '.userlink();
        if($conf['userinfo_debug'] == 1) msg('Debug user info:'.print_r($USERINFO, true), -1);
        return true;
    }
    return false;
}

Now to turn on debugging, set the following in conf/local.php:

$conf['userinfo_debug'] = 1;

To switch off debugging, set the following in conf/local.php:

$conf['userinfo_debug'] = 0;
auth/userinfo_debugging.txt · Last modified: 2018-07-25 23:13 by Aaron Smith