Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.9.4
-
Fix Version/s: None
-
Component/s: Enrolments
-
Labels:None
-
Environment:CentOS 5.3 with standard services and packages
-
Database:MySQL
-
Affected Branches:MOODLE_19_STABLE
Description
There is a problem with auto enrolment with using eDirectory. after some investigation and finding that other people have this issue - http://moodle.org/mod/forum/discuss.php?d=130647 - I investigated further and I think I found the problem. I was able to successfully setup auto enrolment with openLDAP but not with eDir.
My eDir LDAP Enrolment Setup:
student: ou=Students,ou=Moodle,o=ITS | member (not memberUID)
enrol_ldap_objectclass: groupOfNames
enrol_ldap_course_idnumber: cn
enrol_ldap_course_shortname: cn
enrol_ldap_course_fullname: fullName (field added through console1 under "other")
enrol_ldap_course_summary: description
-LDIF of the same record on oLDAP and eDir-
OpenLDAP:
dn: cn=ITSBT,ou=Students,ou=Moodle,o=ITS
objectClass: posixGroup
objectClass: top
cn: ITSBT
gidNumber: 1002
memberUid: jbloggs
description: testing stuff
eDirectory:
<irrelevant lines omitted>
dn: cn=ITSBT,ou=Students,ou=Moodle,o=ITS
fullName: ITS Bypass Test
objectClass: groupOfNames
objectClass: Top
member: cn=jbloggs,ou=STUDENTS,ou=USERS,o=ITS
description: testing stuff
cn: ITSBT
The point I noticed was the difference between what is stored in memberUID under OpenLDAP and member under eDirectory. It looks like the data that's being returned is not being parsed properly.
At Millikin, we have full course automation set up with our Novell system - it automatically syncs users into Moodle and syncs the courses out of eDirectory groups. If you have any questions about our processes, scripts, etc., please feel free to contact us! Here are the code changes that we made to /enrol/ldap/enrol.php to make this work with eDir:
Find this in the code:
// define the search pattern
if (!empty($CFG->enrol_ldap_objectclass)){ $ldap_search_pattern='(objectclass='.$CFG->enrol_ldap_objectclass.')'; } else { $ldap_search_pattern="(objectclass=*)"; }
And replace it with:
// define the search pattern
$ldap_search_pattern="(cn=Moodle)";
We created a new Moodle OU, with sub-OU's of StudentEnrollment and TeacherEnrollment. All of the groups for the courses are stored in those OU's then. For the groups in eDirectory then, add a "Other Name" attribute to the group of "Moodle". If you omit this change, it'll create Moodle classes for all of your eDirectory groups, which obviously isn't desirable.
This next part is the key thing to make it work with eDirectory:
Also, search for:
// insert current enrolments
// bad we can't do INSERT IGNORE with postgres...
foreach ($ldapmembers as $ldapmember) {
$sql = 'SELECT id,1 FROM '.$CFG->prefix.'user '
." WHERE idnumber='$ldapmember'";
$member = get_record_sql($sql);
// print "sql: $sql \nidnumber = $ldapmember \n" . var_dump($member);
if(empty($member) || empty($member->id)){ print "Could not find user $ldapmember, skipping\n"; continue; }
And replace with:
// insert current enrolments
// bad we can't do INSERT IGNORE with postgres...
foreach ($ldapmembers as $ldapmember) {
$sql = 'SELECT id,1 FROM '.$CFG->prefix.'user '
." WHERE username='" . substr($ldapmember,3,stripos($ldapmember,',')-3) . "'";
$member = get_record_sql($sql);
// print "sql: $sql \nidnumber = " . substr($ldapmember,3,stripos($ldapmember,',')-3) . " \n" . var_dump($member);
if(empty($member) || empty($member->id)){ print "Could not find user " . substr($ldapmember,3,stripos($ldapmember,',')-3) . ", skipping\n"; continue; }
This tells Moodle to search for the username instead of the userid field, which isn't used by edirectory or populated in Moodle when used with eDir.