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

LDAP auth plugin doesn't call events_trigger() when user record updated

    Details

    • Testing Instructions:
      Hide

      Testing instructions

      All of the following tests require access to an LDAP server with the Moodle LDAP authentication plugin enabled and configured to connect to this external server. These tests also require administrative access to the LDAP server with the ability to add and remove accounts.

      NOTE: In all of the following queries, replace the mdl_ table name prefix with the value used in your local development environment if not using the default configuration.

      Run the following queries:

      INSERT INTO  mdl_events_handlers (id, eventname, component, handlerfile, handlerfunction, schedule, status, internal)
      VALUES (NULL, 'user_created', 'auth_ldap', '/auth/ldap/auth.php', 'a:2:{i:0;s:16:"auth_plugin_ldap";i:1;s:11:"init_plugin";}', 'cron', '0', '1');
       
      INSERT INTO  mdl_events_handlers (id, eventname, component, handlerfile, handlerfunction, schedule, status, internal)
      VALUES (NULL, 'user_updated', 'auth_ldap', '/auth/ldap/auth.php', 'a:2:{i:0;s:16:"auth_plugin_ldap";i:1;s:11:"init_plugin";}', 'cron', '0', '1');
      

      Queued event check query:

      •     SELECT h.eventname, h.component, h.handlerfile, q.*
              FROM mdl_events_queue q
        INNER JOIN mdl_events_queue_handlers qh ON qh.queuedeventid = q.id
        INNER JOIN mdl_events_handlers h ON h.id = qh.handlerid
             WHERE h.component = 'auth_ldap'
               AND h.handlerfile = '/auth/ldap/auth.php'
               AND h.schedule = 'cron'
               AND (h.eventname = 'user_updated' OR h.eventname = 'user_created');
        

      Queued event purge queries:

      • MySQL:
        •     DELETE q
                FROM mdl_events_queue q
          INNER JOIN mdl_events_queue_handlers qh ON qh.queuedeventid = q.id
          INNER JOIN mdl_events_handlers h ON h.id = qh.handlerid
               WHERE h.component = 'auth_ldap'
                 AND h.handlerfile = '/auth/ldap/auth.php'
                 AND h.schedule = 'cron'
                 AND (h.eventname = 'user_updated' OR h.eventname = 'user_created');
          

      • Other:
        •  DELETE FROM mdl_events_queue
          WHERE EXISTS (
              SELECT q.*
                FROM mdl_events_queue q
          INNER JOIN mdl_events_queue_handlers qh ON qh.queuedeventid = q.id
          INNER JOIN mdl_events_handlers h ON h.id = qh.handlerid
               WHERE h.component = 'auth_ldap'
                 AND h.handlerfile = '/auth/ldap/auth.php'
                 AND h.schedule = 'cron'
                 AND (h.eventname = 'user_updated' OR h.eventname = 'user_created')
          );
          

      user_updated event when creating a new external user

      NOTE: this test requires email sending to be active on your Moodle test site as a confirmation email is sent out during the test.

      1. Log into the site as a site administrator
      2. Navigate to Settings > Plugins > Authentication > LDAP server
      3. Set the Create users externally setting to Yes
      4. Set the Context for new users setting to a valid context on the LDAP server
      5. Click on Save changes
      6. Navigate to Settings > Plugins > Authentication > Manage authentication
      7. Set the Self registration setting to LDAP Server and click on Save changes
      8. Logout of the site
      9. Click on a *Login * link
      10. Click on the Create new account button
      11. Fill out the required fields (be sure to enter an email address that you can receive mail for) and click the Create my new account button
      12. Wait for the confirmation email to arrive and click on the confirmation link in the email
      13. Run the queued event check query listed above
      14. You should see a single user_updated record returned
      15. Run the appropriate database query listed above to purge queued events

      user_updated event when suspending an externally deleted user

      1. Run the CLI script /auth/ldap/cli/sync_users.php to ensure that all of the users from the LDAP server have Moodle accounts created
      2. Log into the site as a site administrator
      3. Navigate to Settings > Plugins > Authentication > LDAP server
      4. Set the Removed ext user setting to the value of Suspend internal and click on Save changes
      5. Remove a user account from the LDAP server that can be found by Moodle (based on the current search configuration within the LDAP auth plugin)
      6. Run the CLI script /auth/ldap/cli/sync_users.php
      7. Run the queued event check query listed above
      8. You should see a single user_updated record returned
      9. Run the appropriate database query listed above to purge queued events

      user_updated event when "reactivating" a previously externally deleted user account

      1. Complete the test above
      2. Recreate the LDAP user account that was removed in step 4 from the test above
      3. Run the CLI script /auth/ldap/cli/sync_users.php
      4. Run the queued event check query listed above
      5. You should see a single user_updated record returned
      6. Run the appropriate database query listed above to purge queued events

      user_created event when adding a new external user account

      1. Create a new user account in the LDAP server that can be found by Moodle (based on the current search configuration within the LDAP auth plugin)
      2. Run the CLI script /auth/ldap/cli/sync_users.php
      3. Run the queued event check query listed above
      4. You should see a single user_created record returned
      5. Run the appropriate database query listed above to purge queued events

      user_updated event when modifying an external user account

      1. Modify an existing user account in the LDAP server that can be found by Moodle (change the firstname and lastname values) based on the current search configuration within the LDAP auth plugin)
      2. Run the CLI script /auth/ldap/cli/sync_users.php
      3. Run the queued event check query listed above
      4. You should see a single user_updated record returned
      5. Run the appropriate database query listed above to purge queued events
      Show
      Testing instructions All of the following tests require access to an LDAP server with the Moodle LDAP authentication plugin enabled and configured to connect to this external server. These tests also require administrative access to the LDAP server with the ability to add and remove accounts. NOTE: In all of the following queries, replace the mdl_ table name prefix with the value used in your local development environment if not using the default configuration. Run the following queries: INSERT INTO mdl_events_handlers (id, eventname, component, handlerfile, handlerfunction, schedule, status, internal) VALUES (NULL, 'user_created', 'auth_ldap', '/auth/ldap/auth.php', 'a:2:{i:0;s:16:"auth_plugin_ldap";i:1;s:11:"init_plugin";}', 'cron', '0', '1');   INSERT INTO mdl_events_handlers (id, eventname, component, handlerfile, handlerfunction, schedule, status, internal) VALUES (NULL, 'user_updated', 'auth_ldap', '/auth/ldap/auth.php', 'a:2:{i:0;s:16:"auth_plugin_ldap";i:1;s:11:"init_plugin";}', 'cron', '0', '1'); Queued event check query: SELECT h.eventname, h.component, h.handlerfile, q.* FROM mdl_events_queue q INNER JOIN mdl_events_queue_handlers qh ON qh.queuedeventid = q.id INNER JOIN mdl_events_handlers h ON h.id = qh.handlerid WHERE h.component = 'auth_ldap' AND h.handlerfile = '/auth/ldap/auth.php' AND h.schedule = 'cron' AND (h.eventname = 'user_updated' OR h.eventname = 'user_created'); Queued event purge queries: MySQL: DELETE q FROM mdl_events_queue q INNER JOIN mdl_events_queue_handlers qh ON qh.queuedeventid = q.id INNER JOIN mdl_events_handlers h ON h.id = qh.handlerid WHERE h.component = 'auth_ldap' AND h.handlerfile = '/auth/ldap/auth.php' AND h.schedule = 'cron' AND (h.eventname = 'user_updated' OR h.eventname = 'user_created'); Other: DELETE FROM mdl_events_queue WHERE EXISTS ( SELECT q.* FROM mdl_events_queue q INNER JOIN mdl_events_queue_handlers qh ON qh.queuedeventid = q.id INNER JOIN mdl_events_handlers h ON h.id = qh.handlerid WHERE h.component = 'auth_ldap' AND h.handlerfile = '/auth/ldap/auth.php' AND h.schedule = 'cron' AND (h.eventname = 'user_updated' OR h.eventname = 'user_created') ); user_updated event when creating a new external user NOTE: this test requires email sending to be active on your Moodle test site as a confirmation email is sent out during the test. Log into the site as a site administrator Navigate to Settings > Plugins > Authentication > LDAP server Set the Create users externally setting to Yes Set the Context for new users setting to a valid context on the LDAP server Click on Save changes Navigate to Settings > Plugins > Authentication > Manage authentication Set the Self registration setting to LDAP Server and click on Save changes Logout of the site Click on a *Login * link Click on the Create new account button Fill out the required fields (be sure to enter an email address that you can receive mail for) and click the Create my new account button Wait for the confirmation email to arrive and click on the confirmation link in the email Run the queued event check query listed above You should see a single user_updated record returned Run the appropriate database query listed above to purge queued events user_updated event when suspending an externally deleted user Run the CLI script /auth/ldap/cli/sync_users.php to ensure that all of the users from the LDAP server have Moodle accounts created Log into the site as a site administrator Navigate to Settings > Plugins > Authentication > LDAP server Set the Removed ext user setting to the value of Suspend internal and click on Save changes Remove a user account from the LDAP server that can be found by Moodle (based on the current search configuration within the LDAP auth plugin) Run the CLI script /auth/ldap/cli/sync_users.php Run the queued event check query listed above You should see a single user_updated record returned Run the appropriate database query listed above to purge queued events user_updated event when "reactivating" a previously externally deleted user account Complete the test above Recreate the LDAP user account that was removed in step 4 from the test above Run the CLI script /auth/ldap/cli/sync_users.php Run the queued event check query listed above You should see a single user_updated record returned Run the appropriate database query listed above to purge queued events user_created event when adding a new external user account Create a new user account in the LDAP server that can be found by Moodle (based on the current search configuration within the LDAP auth plugin) Run the CLI script /auth/ldap/cli/sync_users.php Run the queued event check query listed above You should see a single user_created record returned Run the appropriate database query listed above to purge queued events user_updated event when modifying an external user account Modify an existing user account in the LDAP server that can be found by Moodle (change the firstname and lastname values) based on the current search configuration within the LDAP auth plugin) Run the CLI script /auth/ldap/cli/sync_users.php Run the queued event check query listed above You should see a single user_updated record returned Run the appropriate database query listed above to purge queued events
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-39166-m25

      Description

      LDAP auth plugin doesn't call events_trigger() when user record updated and, if some cases, created.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    8/Jul/13