authentication and enrolment from an external database

authentication and enrolment from an external database

by James M -
Number of replies: 3

Hi,

I want to use an external database for both authentication (loading the users) and enrolment (putting them into the appropriate courses). My external database has (among other things) :
- users table (userid, username, firstname, lastname ...)
coursetouser table (courseid, userid) . this is a bridge table between "users and "courses"

problem I have is that when I do the authentication, the user is loaded into mdl_user table with a new id (this is autoincremented), so when I then go to do the enrolment, the id in the moodle table (mdl_user) doesn't match the id in the external (coursetouser) table.

I thought about importing the id in the external database's user table into the idnumber field of mdl_user, and using that for enrolements. However, I'd like to use that field for a student id we also use.

Has anybody else hit this? Maybe I'm missing something.

thanks,

James

Average of ratings: -
In reply to James M

Re: authentication and enrolment from an external database

by Martín Langhoff -
James,

idnumber is (afaik) meant to store the external db unique identifier. If you use it that way, you will want to block users from changing their idnumber (something you can do with my latest ldap and auth patches).

In that case you can use their current student number as their moodle username, instead of creating a new arbitrary username (and deal with name collision and all the hoopla.

That's what we are doing for Open Polytechnic of NZ (part of nzvle). The moodle username is actually the student id from the student management system. Knowing that this is sometimes hard to remember, I am letting users put their email address in the login box (and we do an email lookup).

The customizations we do as part of the NZVLE project are world-viewable at
http://lists.eduforge.org/cgi-bin/archzoom.cgi/arch-eduforge@catalyst.net.nz--2004-MIRROR/moodle--eduforge--1.3.3

The patch that achieves this is patch-31 (click on the [cset] link, then on the [+] to see the diffs).

This makes Moodle a little bit less secure. Standard moodle is very discreet about usernames, so for someone to impersonate you they will have to guess (or watch you type or sniff on the netwoek) your username and password. If knowing your email equals knowing your username, there's a bit less security. Just a minor thing though, in many enviroments, the usernames are well known for other reasons.

Lastly, if you really need another field to store the external id number, add a field to the mdl_user table, and patch the auth module a bit to store that extra bit of data. Petri has been known to do this with the ldap module ;)

cheers,





martin
In reply to Martín Langhoff

Re: authentication and enrolment from an external database

by James M -

Martin,

Thanks a lot for the info. I think your idea of adding a field to mdl_user and doing the auto modification is the way we'll go. The main reason being that we really want to keep idnumber available for student ID. These are pretty important to us, as they allow a school (we supply services to multiple schools - who have studentIDs in a variety of formats or in some cases no student ID) an extra level of verification on the identity of their student.

We're actually already using the email address as the username for login. Went with this because (1) as you said, it's easy for students to remember and (2) it should always be unique and (3) that's what our shopping cart system uses anyway.

thanks very much,

James

In reply to James M

Re: authentication and enrolment from an external database

by James M -
Just in case anyone follows this forum topic and is interested in the intended meaning of idnumber in mdl_user, Martin D. confirmed in this post: http://moodle.org/mod/forum/discuss.php?d=12291 that "Martin is correct, the idnumber is meant to be the official field for external user-record relationship". So, what I did went against that.