Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-10509

LDAP sync_users fails on usernames with uppercase characters

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6, 1.8, 1.9
    • Fix Version/s: 1.8.4, 1.9, 2.0
    • Component/s: Authentication
    • Labels:
      None
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      auth_ldap_sync_users.php fails with "Cannot update non-existent user" when updating usernames containing capital letters.
      In auth/ldap/auth.php, in function update_user_record(), the following line is converting the username to lowercase, causing the get_record() lookup to fail with no match on the username:
      $username = trim(moodle_strtolower($username));

      Here is an example of the output from auth_ldap_sync_users.php:

      Got 1151 records from LDAP

      User entries to update: 1332
      Updating user ldap.test id 792
      Updating user ann.bolton id 488
      Updating user olivian.roddenby id 1538
      Updating user SBCS - ASP id 590Cannot update non-existent user: sbcs - asp

      Commenting out the strtolower line fixes this.

      Also as a subsequent bug, the update_user_record function in auth/ldap/auth.php calls print_error which prints out a HTML error page, however auth_ldap_sync_users.php is not intended to be called from a web server so should have plain text output suitable for cron emails.

        Gliffy Diagrams

          Attachments

          1. MDL-10509-165.diff
            0.7 kB
          2. MDL-10509-173.diff
            0.7 kB
          3. MDL-10509-183.diff
            0.8 kB
          4. MDL-10509-19beta2.diff
            0.8 kB

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Jan/08