Sudden LDAP 'duplicate entry' error

Sudden LDAP 'duplicate entry' error

by Jason Hollowell -
Number of replies: 2
Picture of Particularly helpful Moodlers

Hello all,

I've just become aware of an LDAP authentication issue on our Moodle site. I've been running LDAP authentication for a couple of years now with no issues. It became apparent that some accounts had not been created (as students were unable to login) and upon investigation, I noticed the LDAP users sync job has not run since June 5th. wide eyes 

Normally, the bulk of our accounts are created, via LDAP, each year in late March (approximately 1,000 users each year). There are a few special cases (international students) via which accounts are created at other times. The inability to create these 'special' accounts is what brought this issue to the surface for us. I attempted to run the script manually from the Scheduled tasks page and get the following error:

Scheduled task failed: LDAP users sync job (auth_ldap\task\sync_task),Error writing to database
Debug info:
Duplicate entry '1-samplename' for key 'mdl_tmpextu_mneuse_uix'
INSERT INTO mdl_tmp_extuser (username,mnethostid) VALUES(?,?)
[array (
  0 => 'samplename',
  1 => '1',
)]
I've changed the actual username to 'samplename'. The account, 'samplename' is one that has been present on the Moodle site for some time (several years). I do not have access to the LDAP server but suspect there may, for some reason, be duplicate entries in the LDAP server. Is that suspicion warranted? And, is there any additional testing I can do on the Moodle site (server) to further track this problem (without access to the LDAP server)?

Thanks in advance for any help that is provided.

Regards

Jason

P.S. I am running Moodle 3.3+   Also, there is no information in my database (MySql) error log that might be helpful (actually no errors at all).

Average of ratings: -
In reply to Jason Hollowell

Re: Sudden LDAP 'duplicate entry' error

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Hello all,

I am replying to my own post here because I managed to figure out the issue. I had added an additional line to the Contexts setting for our LDAP server. I had forgotten about adding it some time back.

The formatting was not a problem but it revealed an issue with our LDAP setup. Namely, one user had two 'accounts' in the LDAP setup. This was not a problem with other systems that use the LDAP for account creation (due to other unique identifiers) but Moodle was throwing and error and the LDAP sync was ceasing each time it hit this error. I removed the additional line (as it is not mission critical) and will work to get the duplicate record removed from our LDAP system. Since the LDAP sync is no longer looking at the context I removed, the sync now proceeds and all desired accounts were created. smile

Regards

Jason

In reply to Jason Hollowell

Re: Sudden LDAP 'duplicate entry' error

by Dennys Patricio Villacrés Jiménez -

Hi Jason. I am living something similar. You mean you erased the context line on LDAP moodle configuration? Is it empty?

Thanks for your help