Пример #1
0
function ldapauth_hook_authenticate($a, &$b)
{
    $mail = '';
    if (ldapauth_authenticate($b['username'], $b['password'], $mail)) {
        $results = q("SELECT * FROM account where account_email = '%s' OR account_email = '%s'  AND account_flags in (0,1) limit 1", dbesc($b['username']), dbesc($mail));
        if (!$results && $mail && intval(get_config('ldapauth', 'create_account')) == 1) {
            require_once 'include/account.php';
            $acct = create_account(array('email' => $mail, 'password' => random_string()));
            if ($acct['success']) {
                logger('ldapauth: Created account for ' . $b['username'] . ' using ' . $mail);
                info(t('An account has been created for you.'));
                $b['user_record'] = $acct['account'];
                $b['authenticated'] = 1;
            }
        } elseif (intval(get_config('ldapauth', 'create_account')) != 1 && !$results) {
            logger('ldapauth: User ' . $b['username'] . ' authenticated but no db-record and. Rejecting auth.');
            notice(t('Authentication successful but rejected: account creation is disabled.'));
            return;
        }
        if ($results) {
            logger('ldapauth: Login success for ' . $b['username']);
            $b['user_record'] = $results[0];
            $b['authenticated'] = 1;
        }
    }
    return;
}
Пример #2
0
function ldapauth_hook_authenticate($a, &$b)
{
    if (ldapauth_authenticate($b['username'], $b['password'])) {
        $results = get_existing_account($b['username']);
        if (!empty($results)) {
            $b['user_record'] = $results[0];
            $b['authenticated'] = 1;
        }
    }
    return;
}
Пример #3
0
function ldapauth_hook_authenticate($a, &$b)
{
    if (ldapauth_authenticate($b['username'], $b['password'])) {
        $results = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1", dbesc($b['username']));
        if (count($results)) {
            $b['user_record'] = $results[0];
            $b['authenticated'] = 1;
        }
    }
    return;
}