User not enrolled by External Database Authentication

User not enrolled by External Database Authentication

by Ângelo Rigo -
Number of replies: 9
Hi

Sorry but i am cross-posting my post on User authentication fórum (http://moodle.org/mod/forum/discuss.php?d=88193), just because now it is a enrollment plugin problem :

Hi

Need some help to enroll external users into existing courses.

I am syncing successfully the users from a external database users.

Now i am not enrolling these users into existing courses.

I have a course in moodle_course table with idnumber = "ct101"
and that is what i have in my external database too.

I have in my external database these collumns and this record:

id | user | course | firstname | lastname | email | city | country | enroll
8 991802 ct101 External Student external@domain.com New York US student

I run auth/db/auth_db_sync_users.php and the record was copied to moodle_user table,
(now i have this user in moodle user table with the value "db" in the auth collumn).

I run cron several times and receive the password. (did not understand yet when or why is done the password generation)

I run enrol/database/enrol_database_sync.php

I change the password at the first login .

I login again with the new password but i did not get enrolled with the expected course, whose idnumber value in moodle_course is ct101

My field mapping in course>enrollments is (local->remote):
idnumber->course
idnumber->user
shortname->enroll

Is there anything wrong ?
The only problem i have is that i do not get the user enrolled !

Thank´s in advance!
Average of ratings: -
In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
Now it is resolved i change enrol_remoteuserfield to id and not user .
In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
One doubt :

To enroll users i first must run enrol_database_sync.php

And after i must run admin/cron.php!

What exactly enrol_database_sync.php does and what exactly cron.php does?

The users will not be enrolled at a course untll cron.php runs, after enrol_database_sync.php have run ?
In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

enrol_database_sync.php only deals with course enrolments from an external database. cron.php runs many different scheduled taks, and you should run it periodically (most people run it every 5 minutes).

For users to be enrolled in a course, the users have to exist in Moodle (so you might need to run auth_*_sync.php for this to happen) and then you can run enrol_database_sync.php.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
Thank´s Inãki

So when running enrol_database_sync.php the already existing user data (sincronized from auth_*_user_syn.php) will be associated to the existing courses and the role_assignment table will be populated with the user, context-course data !?

As i choose internal method to manage password the user will receive the password after a cron running !?

Saludos. Ângelo.
In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
Hi
On this setting : "Cron synchronization script Removed ext user"

How does these options works!
1. "Keep internal"
2. "Suspend internal"
3. "Full delete internal"

"Specify what to do with internal user account during mass synchronization when user was removed from external source. Only suspended users are automatically revived if they reappear in ext source."

During synchronization the users are deleted from moodle internal user table and we have three diferent ways to do it ?
that is it ?
how each of them work ?

Thank´s in advance
In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
How do i sync one user in more than one course?
my mapping is working for only users only just into one course

When i have :
user | course
991802777 | ct101
991802777 | CF101

auth/db/auth_db_sync_users say Duplicatwed entry for user 991802777

I was expecting this user would get enrolled at the two courses .

Thank´s in advance



In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
My actual mapping
auth: (local->remote)
username field -> user
id number -> user

enrol: (local->value|remote)
course->idnumber|course
user->idnumber|user
In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Ângelo Rigo -
These are the settings i have,

I can assign one user to none course this is working fine !

My problem is that i can not assign one user to more than one course !

Actually it fails in auth/db/auth_db_sync_users.php if i have two records for the same username

How can i assign one user to more than one course ?

user_course table structure :

id
user
course
firstname
lastname
email
city
country
enroll

Settings:
Auth Enrol

Username field: user enrol_localcoursefield: idnumber
Password format: internal enrol_localuserfield: idnumber
Firstname: firstname enrol_db_localrolefield: shortname
Lastname: lastname
Email: email enrol_remotecoursefield: course
City: city enrol_remoteuserfield: id
Country: country enrol_db_remoterolefield: enroll
Nº ID: id

Thank´s in advance


In reply to Ângelo Rigo

Re: User not enrolled by External Database Authentication

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I know I'm a bit late, but better late than never smile

You need to use two different tables: one for authentication and another one for enrolment.

The reason is the authentication code expects the user table has only one row for each user, with all the details for that user, but nothing related to courses

Then you have a separate table with the enrolment data, where you can have as many rows as you need for any user (in fact, you'll only need the user 'identifier' in this table).

Saludos. Iñaki.