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; }
xml_header(); $retval = db_init_xml(); if ($retval) { 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);