Create account and pass authentication details to moodle

Create account and pass authentication details to moodle

by David Smith -
Number of replies: 3

I am trying to have a single sign on environment from one of our house built apps to our Moodle environment.  Basically the user will authenticate to our house built app and then click a link which will point them to (something like this):

http://[SITE]/elearning/login/index.php?userid=12345&firstnm=David&lastnm=Smith&courseid=6&flag=T&session_id=1234567890

With the information in the query string I would like to do one of two things:

  • Log the person into the Moodle course
  • If the person doesn't have an account in Moodle, create the account with the information provided in the query string and then log them into moodle

Does anyone know if this is possible and how to do about it?

Thanks.

Average of ratings: -
In reply to David Smith

Re: Create account and pass authentication details to moodle

by Richard Crawford -

I wish I had some wisdom to share with you, since we're facing exactly the same question at our institution. If I figure anything out, I will share it with you.

Meanwhile, consider this topic "bumped".;)

In reply to Richard Crawford

Re: Create account and pass authentication details to moodle

by Hugh Edwards -

I would do this with a stored procedure on the DB rather than putting it all into an open (and so unsecure) query string with user account details, and pass the stored procedure certain variables. 

We've done this already, and there are quite a few moodle tables that you need to enter data for, for example, mdl_user, mdl_user_preferences, mdl_user_enrolments, mdl_role_assignments, and mdl_forum_subscriptions.

It's not too difficult for someone who knows how to create stored procs. smile 

You can then choose to use External Database for authentication or the standard moodle authentication. 

I hope that helps. 

Hugh. 

 

In reply to David Smith

Re: Create account and pass authentication details to moodle

by toby saunders -

To log someone into moodle I used

authenticate_user_login($user->username, $plain_password);
complete_user_login($user);

I did this in my auth plugin in the user_signup function and it worked to log the user in at the same time as signing them up. You will probably want to redirect them somewhere useful afterwards.

Hope this helps