Problem while creating a new user

I’m trying to create a new Camunda user with Camunda Admin and with Java API. From both ways I can’t set a password for the new user.
With Java API I’ve used the following code:

User user = identityService.newUser((String) execution.getVariable("username"));
user.setPassword((String) execution.getVariable("password"));
user.setFirstName((String) execution.getVariable("firstName"));
user.setLastName((String) execution.getVariable("lastName"));

This creates a new user with the given ID, first name and last name but the password is null.
I’ve even created some users with the Camunda Admin interface and all seems to works good (in this way I’m forced to insert a non null password) but when I execute the following code

for (User user : identityService
            .list()) {
        System.out.println(user.getId()+" "+user.getPassword());

all the users have the same sha value ({SHA}AOodpBkqIDD5rgI947MUPtZHu6s=) as those with null password.
Where I’m wrong?
I’m using Camunda 7.5.0

P.S. If I call


for a newly created user it gives me null but the one in the for cycle up there gives me {SHA}AOodpBkqIDD5rgI947MUPtZHu6s=. Why?

I’m also creating users using the Java API. But other than you I set all paramenters first and then call saveUser.
And attributes are as they are expected to be.
I wonder how the users you created can have more than just a name.
Or is there another saveUser call you did not show to us?
Please try this:

User user = identityService.newUser((String) execution.getVariable(“username”));
user.setPassword((String) execution.getVariable(“password”));
user.setFirstName((String) execution.getVariable(“firstName”));
user.setLastName((String) execution.getVariable(“lastName”));

I’ve tryied in both ways but the result was the same. However it doesn’t explain why I can’t set the password even if I use Camunda Admin.
I’ve posted all the code of interest.

The problem is solved. I’ve tryied to call the saveUser for last and it works.
I still can’t understand why setFirstName and setLastName works after the saveUser call and setPassword doesn’t but it’s fine.

You should first use identityService#newUser and set a password yourself. Then call the saveUser method.

org.camunda.bpm.engine.identity.User camundaUser = identityService.newUser(userId);


At least that is how I do it :stuck_out_tongue: Never had any issues