Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled task sync issue #1108

mmulrthelp opened this issue Mar 21, 2019 · 3 comments

Scheduled task sync issue #1108

mmulrthelp opened this issue Mar 21, 2019 · 3 comments


Copy link

@mmulrthelp mmulrthelp commented Mar 21, 2019


We've setup all the Microsoft plugins on our Dev server and everything is working apart from the sync'ing of users from Azure AD. On running the Scheduled task 'Sync users with Azure AD' I get the following outputted to screen and nothing is then updated for the user in the database, does the user need to authenticate before the mdl_user table updates?

We are running:
Moodle 3.6.2
repository_office365 : (2018051700)
auth_oidc : (2018051703)
MySQL database: 5.7.21-20-log

All downloaded from Moodle plugins site - is this where my issues lie, should I be using the latest git release?

Error received:

......... Syncing user
......... Assigning Moodle user 30 (objectid 3c1a8a67-1234-4ace-bc38-22b0e4aa973e) to application
......... Could not assign user "" Reason: No token available for usersync
......... Found a user in Azure AD that seems to match a user in Moodle
......... moodle username: studentID, aad upn:
......... User is already matched.
......... User is now synced.

I've noticed there's two mdl_local_o365_token tables in the database, one contains columns and indexes and the other one doesn't, could this be my issue, see image of tables below


To note it only seems to run 200 full sync'd users at a time, not 1000, like it says.

Copy link

@mmulrthelp mmulrthelp commented Mar 27, 2019

I got to the bottom of the above, by doing it via SQL on the database:

UPDATE mdl_user 
SET username = concat(ifnull(username,""), ''), auth = 'oidc'
WHERE  auth = 'ldap'
	AND username regexp '^[0-9]{8}$' 
	AND email like '';

The regex above is just matching account with only 8 digits

Copy link

@jamesmcq jamesmcq commented Mar 29, 2019

Hi @mmulrthelp - The version on is the latest stable version, so you're good there. Make sure you have the latest version from though - what version is your local_o365?

I'm not sure why you have two tables though... They're both named the same though, maybe this is an issue with the database viewing application? Strange.

Looking at the output you posted, it looks like this user is a "matched" user - i.e. they have not yet logged in to the site, correct? A "matched" user just sets up a user for a future connection, but the user has to actually log in to the Moodle site using their Office 365 credentials to complete the connection. User information syncing will only happen after this connection has been completed.

Copy link

@mmulrthelp mmulrthelp commented Mar 29, 2019

Hi @jamesmcq - The above now makes sense. The part about the sync match could do with being in the manual, I'm sure it's confused others as well.
I've been testing it all on our dev server before hopefully going live with it this summer, therefore I've not had students logging in. Just some colleagues, but didn't get them to try before I had done the above SQL.
I solved the part with the two identical database tables by uninstalling the office 365 plugins, checking the database tables where removed and reinstalling.

I'm using : Microsoft Office 365 Integration local_o3650 2018051706

Many thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants