Beispiel #1
0
<?php

require_once "../inc/util_ops.inc";
require_once "../inc/user.inc";
admin_page_head("Add User");
$email = get_str('email', true);
$name = get_str('name', true);
if ($email && $name) {
    $user = make_user_ldap(urldecode($email), urldecode($name));
    if ($user) {
        echo "User created with ID ";
        echo $user->id;
    } else {
        echo "ERROR: couldn't create user, probably email address already in DB";
    }
} else {
    $page = $_SERVER["REQUEST_URI"];
    echo "<form action=\"{$page}\" method=\"get\" enctype=\"application/x-www-form-urlencoded\">\n";
    echo '<p>User name: ';
    echo '<input name="name" type="text" size="100" maxlength="200">';
    echo '</p><p>Email address:: ';
    echo '<input name="email" type="text" size="100" maxlength="200">';
    echo '</p>';
    echo '<input type="submit" value="Create user">';
    echo "</form>\n";
}
Beispiel #2
0
function login_with_ldap($uid, $passwd, $next_url, $perm)
{
    list($ldap_user, $error_msg) = ldap_auth($uid, $passwd);
    if ($error_msg) {
        error_page($error_msg);
    }
    $x = ldap_email_string($uid);
    $user = BoincUser::lookup_email_addr($x);
    if (!$user) {
        // LDAP authentication succeeded but we don't have a user record.
        // Create one.
        //
        $user = make_user_ldap($x, $ldap_user->name);
    }
    if (!$user) {
        error_page("Couldn't create user");
    }
    Header("Location: " . url_base() . "{$next_url}");
    send_cookie('auth', $user->authenticator, $perm);
    return;
}
Beispiel #3
0
    xml_error($retval);
}
$ldap_auth = get_str("ldap_auth", true);
if (LDAP_HOST && $ldap_auth) {
    // LDAP case.
    //
    $ldap_uid = get_str("ldap_uid");
    $passwd = get_str("passwd");
    list($ldap_user, $error_msg) = ldap_auth($ldap_uid, $passwd);
    if ($error_msg) {
        xml_error(ERR_BAD_USER_NAME, $error_msg);
    }
    $x = ldap_email_string($ldap_uid);
    $user = BoincUser::lookup_email_addr($x);
    if (!$user) {
        $user = make_user_ldap($x, $ldap_user->name);
        if (!$user) {
            xml_error(-1, "user record creation failed");
        }
    }
} else {
    // normal (non-LDAP) case
    $email_addr = get_str("email_addr");
    $passwd_hash = get_str("passwd_hash", true);
    $email_addr = BoincDb::escape_string($email_addr);
    $user = BoincUser::lookup("email_addr='{$email_addr}'");
    if (!$user) {
        xml_error(ERR_DB_NOT_FOUND);
    }
    if (!$passwd_hash) {
        echo "<account_out>\n";