Issue Details (XML | Word | Printable)

Key: MDL-17682
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Petr Skoda
Reporter: Domenico Pontari
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Moodle cannot create a new record on user table when a new LDAP entry wants to authenticate

Created: 18/Dec/08 08:05 PM   Updated: 21/Feb/09 07:35 AM
Return to search
Component/s: Authentication
Affects Version/s: 1.8.5, 1.8.6, 1.8.7, 1.9, 1.9.1, 1.9.2, 1.9.3
Fix Version/s: 1.8.8, 1.9.4

URL: cvs:/lib/moodlelib.php
Participants: Domenico Pontari, Hannes Fuchs and Petr Skoda
Security Level: None
Difficulty: Easy
Resolved date: 30/Dec/08
Affected Branches: MOODLE_18_STABLE, MOODLE_19_STABLE
Fixed Branches: MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
Environment: a new LDAP entry try to authenticate for the first time in Moodle and still there isn't a record in mdl_user table.

When this new user try to authenticate, authenticate_user_login function is called. If the credentials are correct, it search the correct record in mdl_user table without success and it calls create_user_record.
This function try to create a new record, but this is the error message:

Field 'city' doesn't have a default value

INSERT INTO mdl_user ( AUTH, CONFIRMED, MNETHOSTID, USERNAME, FIRSTNAME, LASTNAME, LANG, LASTIP, TIMEMODIFIED ) VALUES ( 'ldap', 1, 1, 'd.eliseo', 'Donato', 'Eliseo', 'it_utf8', '10.250.1.21', 1229596730 )
line 1425 of lib/dmllib.php: call to debugging()
line 2603 of lib/moodlelib.php: call to insert_record()
line 2787 of lib/moodlelib.php: call to create_user_record()
line 126 of login/form.php: call to authenticate_user_login()

infact City Field is a nonull param as you see in cvs:/lib/db/install.xml without default value

Solution: adding something like:
$newuser->city = '';
in create_user_record function in cvs:/lib/moodlelib.php

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Petr Skoda added a comment - 30/Dec/08 06:48 AM
should be fixed in cvs, please test and reopen if needed.

thanks for the report!


Hannes Fuchs added a comment - 18/Feb/09 07:31 AM
i have the same problem, but use a 1.9.4+ version and have checked and found the described fix in source of lib/moodlelib.php

with older 1.9.2+ the ldap connection with creating users works and now after upgrading it seems to be broken.
if i add the user directly to user table with following minimum fields set auth=ldap, confimed=1, mnethostid set an username set, then i am able to login with the ldap provided user with all correct data from ldap (password, firstname, surname and so on). without adding him i could not log in. already existing users in user-table works with no problem.

are there other new fields like 'city' which are required since v1.9.2?

regards
hannes


Petr Skoda added a comment - 21/Feb/09 06:15 AM
there should not be any changes in user table structure in 1.9.x, could you please try to turn on full debugging and look up the error in logs?

you can put following into config.php if you want to turn on full debug temporarily:
@ini_set('display_errors', '1');
$CFG->debug = (32768 | 4096 |E_ALL);
$CFG->debugdisplay = true;
@error_reporting($CFG->debug);


Hannes Fuchs added a comment - 21/Feb/09 06:29 AM
i got the following...

Column 'lastip' cannot be null

INSERT INTO seminare_elatest___user ( AUTH, CONFIRMED, MNETHOSTID, USERNAME, FIRSTNAME, LASTNAME, EMAIL, CITY, COUNTRY, LANG, LASTIP, TIMEMODIFIED ) VALUES ( 'ldap', 1, 1, 'XXXuserXXX', 'XXXpwXXX', 'XXX', 'XXXX@schule.at', 'XXX', 'AT', 'de_utf8', null, 1235165215 )

  • line 1554 of lib/dmllib.php: call to debugging()
  • line 2911 of lib/moodlelib.php: call to insert_record()
  • line 3143 of lib/moodlelib.php: call to create_user_record()
  • line 128 of login/index.php: call to authenticate_user_login()

Hannes Fuchs added a comment - 21/Feb/09 07:35 AM
it seems that getremoteaddr() runs through the whole function and returns the null value.
maybe this return value can be edited to an allowed value like '0.0.0.0' or '255.255.255.255'

i have made a simple patch in my local lib/moodlelib.php now, so it now runs again.

      1. within create_user_record() ###
        $newuser->lastip = getremoteaddr();

if (!isset($newuser->lastip)) { $newuser->lastip = '0.0.0.0'; }
###