Integration with external system users?

Integration with external system users?

by Aaron Zeckoski -
Number of replies: 3
I want to set the current user in moodle by passing in some encoded information from an external system. I don't have a single sign-on system but I do have the user information in one system which I want to pass to moodle. Is there an easy way to override the current user session information or should I be looking at a different way to handle this entirely?
Average of ratings: -
In reply to Aaron Zeckoski

Re: Integration with external system users?

by Hubert Chathi -
Take a look at the code in auth/mnet/land.php to see how Moodle Networks does this. It looks fairly simple.
In reply to Hubert Chathi

Re: Integration with external system users?

by Aaron Zeckoski -
I looked at the code and I am not sure I follow this. It seems like there is code in the auth directory which is related to the various providers. I tried creating a plugin which extends auth_plugin_base but I can't find a way to get it to log me in automatically by calling this provider.

What I really need to be able to do is cause the user to be logged in automatically when accessing the url for a course which includes a proper set of parameters. We don't want users to have to login to moodle separately and instead want to simply send the credential info along to the destination page. Is there a good way to handle this (we cannot use CAS here)

In reply to Aaron Zeckoski

Re: Integration with external system users?

by Hubert Chathi -
I think that once you have verified the authentication parameters, you just need to do something like:

// log in
$USER = get_complete_user_data('id', $localuser->id, $localuser->mnethostid);
complete_user_login($USER);

(around line 34 in /auth/mnet/land.php) get_complete_user_data can look up users using different fields, and you'll probably want to skip the last parameter.

/auth/mnet/land.php is the file that you get redirected to when you want to log into a remote Moodle using Moodle Networks, and it causes the user to be logged in automatically.