How to automatically create a user if not exist


we are using our AD Ldap to authenticate the user in Cuba.
But, if the user does not exist inside the Cuba user entity,
we are getting an error message.
Because of hundreds of user which could use the App,
we cannot create them manually.

How to create a user with default role and group when the login fails because the user does not exist in Cuba user entity?
I cannot find the class where to inject the needed code even after reading the documentation.


Hi, I am not goot at the LDAP-integration topic, but as for external auth using OAuth2, you can see an example of on-the-fly user creation in demo project sample-social-login, may be it will help you to come up with a solution with LDAP. See this class.


You can replace existing LdapLoginProvider bean in web-spring.xml as it is mentioned in Web Login - CUBA Platform. Developer’s Manual.

At the moment, it requires overriding of the entire login method, but we will simplify this task the future:

Hi, thx for your help.
But, do not know what to do…
Will wait for Konstantin to help me via Slack :frowning: