diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php
index 3f8e2aa2fd5..6c9ee752b33 100644
--- a/auth/mnet/auth.php
+++ b/auth/mnet/auth.php
@@ -291,18 +291,16 @@ class auth_plugin_mnet extends auth_plugin_base {
// TODO: refactor into a separate function
if (empty($localuser) || ! $localuser->id) {
if (empty($this->config->auto_add_remote_users)) {
- print_error('nolocaluser', 'mnet');
+ print_error('nolocaluser2', 'mnet');
}
$remoteuser->mnethostid = $remotehost->id;
$remoteuser->firstaccess = time(); // First time user in this server, grab it here
- if (! insert_record('user', addslashes_recursive($remoteuser))) {
+ if (!$remoteuser->id = insert_record('user', addslashes_recursive($remoteuser))) {
print_error('databaseerror', 'mnet');
}
$firsttime = true;
- if (! $localuser = get_record('user', 'username', addslashes($remoteuser->username), 'mnethostid', $remotehost->id)) {
- print_error('nolocaluser', 'mnet');
- }
+ $localuser = $remoteuser;
}
// check sso access control list for permission first
diff --git a/lang/en_utf8/mnet.php b/lang/en_utf8/mnet.php
index 55a4cb00d9d..505b3421901 100644
--- a/lang/en_utf8/mnet.php
+++ b/lang/en_utf8/mnet.php
@@ -216,6 +216,7 @@ $string['hostnotconfiguredforsso'] = 'This remote Moodle Hub is not configured f
$string['authmnetdisabled'] = 'Moodle Networking authentication is disabled.';
$string['unknownerror'] = 'Unknown error occurred during negotiation.';
$string['nolocaluser'] = 'No local record exists for remote user.';
+$string['nolocaluser2'] = 'No local record exists for remote user, and it could not be created, as this host will not auto create users. Please contact your administrator!';
$string['databaseerror'] = 'Could not write details to the database.';
$string['ssoacldescr'] = 'Use this page to grant/deny access to specific users from remote Moodle Network hosts. This is functional when you are offering SSO services to remote users. To control your local users\' ability to roam to other Moodle Network hosts, use the roles system to grant them the mnetlogintoremote capability.';
$string['ssoaclneeds'] = 'For this functionality to work, you must have Moodle Networking On, plus the Moodle Network authentication plugin enabled with auto-add users enabled .';