SAML2 Auth: Prevent account creation after the first authentication

SAML2 Auth: Prevent account creation after the first authentication

by Charlie Villa -
Number of replies: 3

Hi guys.

I am currently trying to configure my Moodle as a Service Provider (SP) using SAML. I have already configured correctly my Identity Provider (IDP). And to be able to contact it from my Moodle (SP) I am using the plugin: SAML2 Single sign on.

Everything is fine up to a certain point.

When I try to authenticate for the first time from Moodle, everything works great. However if I logout and log in again I get the following error:

Login error
Can't create a new account, because xxxxx@xxxx.xxx email address is already registered


And the authentication is not successful.

I have configured the plugin to register the user account in Moodle the first time I perform the authentication (using the plugin option: Auto create users).

I don't understand the inner workings, but shouldn't it bypass this if the account is already in the system?

I have also seen that in the general authentication section there is an option called: Prevent account creation when authenticating. But I have it disabled, because I want the account to be created when the user authenticates for the first time.

My questions: How do I get the user to authenticate and the system does not try to create the account in moodle if it is already created? Because at the moment I can't re-authenticate.

What changes should I make in the system, should I program something?

Average of ratings: -
In reply to Charlie Villa

Re: SAML2 Auth: Prevent account creation after the first authentication

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
My guess is that you are not mapping the username correctly and so it is not correctly linking to the created account and thinking that you are wanting to create new one...
In reply to Emma Richardson

Re: SAML2 Auth: Prevent account creation after the first authentication

by Charlie Villa -
Thank you very much for the answer, in fact the problem was the mapping of the attributes. Everything works fine now.
In reply to Charlie Villa

Re: SAML2 Auth: Prevent account creation after the first authentication

by Shivanesh Lal -
Hi Charlie,

we are facing the same issue could you please share what mappings did you update please.
our case is on first attempt the users account is created and logs in however after logging out user get the same message.
Can't create a new account, because email address is already registered.