microsoft / o365-moodle

Office 365 and Azure Active Directory plugins for Moodle
GNU General Public License v3.0
180 stars 136 forks source link

Performance issue of synchronization for a large installation #2543

Open bothmani opened 5 months ago

bothmani commented 5 months ago

Hello, Technical environment :

Active options:

Questions:

1- How can I optimize processing time? 2- Is there a way to only retrieve users from the "Moodle-access" group? 3- If a user is removed from the group, they remain active on Moodle. Is there a way to deactivate them when they no longer belong to the authorized group?

Thank you in advance. Regards,

weilai-irl commented 3 months ago

Hi @bothmani

First of all, let me run through the user sync task logic to confirm what you have experienced.

So to answer your questions:

  1. The easiest way to optimise the processing time is to use delta sync rather than full sync. This will require disable the "Perform a full sync each run" option. After this change, the first scheduled task would be the same as the current task run, i.e. taking 8 hrs to finish; however, all subsequent runs will only receive Microsoft users whose account details have changed since the last delta sync. In most cases, this will significantly reduce the task run time.
  2. As explained above, currently this is not possible. Technically we can update the logic to process user creation restrictions on group name or ID to fetch user IDs of members of groups matching the criteria in bulk to reduce the number of API request. We just didn't have the necessity to do it to date - the delta sync approach solves most of the issues. You can make a separate change request for it, and it will be processed in due course.
  3. Technically there is a way. If you configured your Azure app to require assignment to access, then configure to only allow your "Moodle-access" group to access the app, then effectively non-members of the group will not be able to login to use the Azure app, therefore will lose access to Moodle. Note that the user sync task will still process them; if they have existing accounts in Moodle, their accounts will not be deleted, but they won't be able to login using auth_oidc. If you move a user out of the group, they will lose Moodle access; if you move a user into the group, they will gain Moodle access. To configure it, in your Azure portal, go to Enterprise applications, and find the Azure app. On the Properties page, set "Assignment required?" to "Yes", and on the "Users and Groups" page, add individual users or groups. See screenshots attached.

Hope these help.

Regards, Lai

Screenshot 2024-06-07 at 17 03 54 Screenshot 2024-06-07 at 17 06 24