o365-moodle icon indicating copy to clipboard operation
o365-moodle copied to clipboard

Feature request: Modify Moodle usernames / remove domain name from username

Open GC-ABlyth opened this issue 2 years ago • 2 comments

Hi,

Would it be possible to have an option that lets you modify what is set as the Moodle username for both new and synced accounts when "Match Azure usernames to moodle emails instead of moodle usernames during the sync" is enabled?

If all users have UPNs which end in @domain.com regex could be used to select only the text that precedes the domain and set that as the username. For example, using .*([email protected]) - "[email protected]" would become "exampleuser".

Our Moolde has other plugins which require the username to not have the domain at the end, and we are not able to change the UPN of the users. So currently we are unable to automatically create accounts.

If there is another way of achieving this without the above feature (or similar) being implemented please let me know.

Thanks

GC-ABlyth avatar Feb 28 '23 12:02 GC-ABlyth

sounds like a duplicate of #2157 - which we (UCL) are in the process of funding, once the paperwork finally goes through

aspark21 avatar Mar 20 '23 15:03 aspark21

fwiw we made a small adjustment to /classes/loginflow/authcode.php l595 311 branch

$username = $idtoken->claim('upn'); $userarr = explode("@", $username, 2); $username = $userarr[0];

which has worked ok up to now, however we aim to switch it back to the default UPN.

A question: @weilai-irl - i notice when altered there is then a token mistmatch - what is the best workflow to avoid this when we switch back to full UPN? clear out tokens?

MURBASLMS avatar Mar 30 '23 06:03 MURBASLMS