Multiple Courses using same LDAP Group/Course ID Number

Multiple Courses using same LDAP Group/Course ID Number

by Ian Fogarty -
Number of replies: 6
Hi

We have LDAP authentication running on a staff intranet moodle. We were finding that as new staff logged in (the auth_ldap_sync_users.php is not in use atm due to the AD 1000+ users issue - more so, I havent properly resolved it yet for our site), they were getting the do you want to enrol onto this course box.

As this is for staff, we ideally want all staff to automatically be enrolled on all courses. I thought, a solution for this, would be ldap auto-enrollment and use the same Course ID Number for all of the common courses. This matches with a group where all staff are located in, within active directory.

The problem I have found though is the way the enrol_ldap script runs, when a new user logs onto a moodle with 2+ courses setup with the same Course ID Number (for this sake, say MG1), the user will only be automatically enrolled onto the course with the lowest course id number (the primary key of the course table - not the one used for the auto-enrollment) with the other courses staying un-enrolled. As a work around, i thought to run the enrol_ldap_sync.php script but found the following output...

== Synching MG1
Error: Turn off debugging to hide this error.

SELECT * FROM mdl_course WHERE idnumber = 'MG1' LIMIT 100

Found more than one record in get_record_sql !

The SQL then regurgitates all of the courses which are setup with the common Course ID Number.

My main question is either, does anyone know of how to hack moodle to over look this issue and enrol all users to all courses OR does anyone know of an alternative method which would suit our situation?

Any advice/help would be gratefully received.

Thanks

Ian
Average of ratings: -
In reply to Ian Fogarty

Re: Multiple Courses using same LDAP Group/Course ID Number

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
The LDAP enrolment plugin assumes course ID Numbers are unique. This is why you get the warning above (the code is searching for a/one course and it's getting dozens of courses, which is not normal). Then it picks up the first one and ignores the rest.

Patching the LDAP enrolment plugin to cope with multiple courses with the same ID Number shouldn't be that difficult, but you'll have to apply the modifications every time you upgrade Moodle.

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Multiple Courses using same LDAP Group/Course ID Number

by Ian Fogarty -

Thanks for the reply Inaki

You always seem to come up with answers to my unusual questions! I will most probably spend the day tomorrow trying to hack this. If successful, will let you know of the mods.

The question was more me being lazy seeing if anyone else has encountered this!

Ian

 

In reply to Ian Fogarty

Re: Multiple Courses using same LDAP Group/Course ID Number

by Ian Fogarty -

I have spent that last week trying to get this to work but with absolutely no joy. I don't suppose anyone has any pointers or hints to help me with this. As said before, the intention of this moodle is for use as a staff intranet and by displaying the enrol onto a course message i think will really confuse things with some of our staff.

At present the code I have is by editing the enrol.php (attached) file <moodle>\enrol\ldap\enrol.php. I have been editing around line 232 in the function sync_enrollments.

I have substituted the get_record for the get_records and then used the output of that in a foreach loop (I have commented out some of the course create stuff as we do not use it and I thought it would make it easier for debugging and development.

I would be extremely grateful if someone could look at this for me to see where I am going wrong. I am sorry that it is a bit messy and with non-standard syntax but things have been moved all over the place in an attempt to get this thing working.

The ldap group which maps up with the generic courseid numbers holds 1353 users. Would the PHP page size LDAP problem be the issue here? If so, I know Inaki mentioned that PHP could be re-compiled. Does anyone know of any urls which could help to do this? I do not know much about compiling things on Win32 except simple hello world problems with Borland C++. Would this be the correct method?

If this is quite a complex issue, would the changing Active Directory solution be better and if so, we run multiple domain controllers, would this change have to be made to them all or just the ones that moodle queries and if there are any security/performance implications by making this change?

I am sorry for being such a pain in asking these questions but I am running out of ideas on how to get our moodle working ready for "live" time in a few weeks.

Thanks

Ian

In reply to Ian Fogarty

Re: Multiple Courses using same LDAP Group/Course ID Number

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 would be extremely grateful if someone could look at this for me to see where I am going wrong.

It was easier to do the modifications myself than looking through your code smile, so I have attached a modified enrol/ldap/enrol.php file that does what you want.

I've done a few tests and it seems to work ok (both enrolment during login, and the sync script). I haven't done any testing with meta-courses, so I cannot confirm if it works or not.

Bear in mind that this setup is quite uncommon and that you'll need to re-apply the modifications to newer versions of Moodle. Don't just overwrite newer versions of the file with the one I'm attaching here. You migth break Moodle completely.

The ldap group which maps up with the generic courseid numbers holds 1353 users. Would the PHP page size LDAP problem be the issue here?

Yep, you'll run into that problem. I suspect raising the default AD limit would be far easier than recompiling PHP. Specially given that you don't need to raise it too much (1500 should be enough). Performance won't suffer that much when you run the sync script (and none at all when users login).

Just search MS TechNet to see how to raise the query limit on Active Directory.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Multiple Courses using same LDAP Group/Course ID Number

by Steve Power -

Iñaki

Thanks for this I too have been attempting to modify enrol.php to cope with the same issue. Here we are using moodle courses for units of work and so each course of study (and hence group of students) may well have six or more units in a level. I hoped to associate these with the same code and hence enrol the same group of students.

Now back to the other problems caused by AD enhancements which cause incompatability with standard LDAP.

BTW we have increased our default AD limit (to 65000). It has not caused any performance problems with AD but equally it has not solved the 1000 response problem. I currently have a list of more than 30 OU's in my ldap contexts in user lookup settings to get around this problem.

Regards
Steve

In reply to Steve Power

Re: Multiple Courses using same LDAP Group/Course ID Number

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

BTW we have increased our default AD limit (to 65000). It has not caused any performance problems with AD but equally it has not solved the 1000 response problem. I currently have a list of more than 30 OU's in my ldap contexts in user lookup settings to get around this problem.

If you have raised the limit in all the servers you query (and rebooted them; I don't remember if this was required but I did it anyway), then you PHP should be able to pull more than 1000 objects per query (and up to your new limit).

Other than raising the limit or using so many OUs as you do, the only other option is patching PHP with my paged results patch and recompile it.

Saludos. Iñaki.