Create user and assign specific roles programmatically

I need to create users and assign default roles for several thousands of employees as user. I want to do this programmatically from the employee code as user ID, specific password that will be reset and user will change it in first successful log in.

How can I create users, set password, assign roles, set reset password options etc. Will this be possible? Thanks.

I tried with the creation of users in Entity User as well as assigned Roles and it worked successfully to create users. I have used the last employee name with some texts while creating the user programmatically however, login is failed as the password is encrypted that we know. Can someone help how can I use the way how CUBA is encrypting user-entered passwords so that I can use the same before saving the password?

Do you mean CUBA or Jmix? If you mean CUBA, please ask the question in the corresponding forum.

If you mean Jmix, then the password encoding code is located in the User Editor screen which is scaffolded in every project:

    private PasswordEncoder passwordEncoder;


See UserEdit class in your project.