Create users
Hi.
If you want to create a user with an email you can do this :
import org.bonitasoft.engine.identity.UserCreator;
ContactDataCreator contactDataCreator = new ContactDataCreator();
contactDataCreator.setEmail("truc@machin.fr");
UserCreator userCreator = new UserCreator("UserName", "Password");
userCreator.setPersonalContactData(contactDataCreator);
userCreator.setFirstName("Firstname");
userCreator.setLastName("LastName");
apiAccessor.getIdentityAPI().createUser(userCreator);
Hola amigos necesito el código para añadir el rol y grupo a un usuario al crearlo? xf gracias
Comments
import org.bonitasoft.engine.identity.Role;
try {
Group group = apiAccessor.getIdentityAPI().createGroup("GroupName", "ParentGroup");
Role role = apiAccessor.getIdentityAPI().createRole("RoleName");
apiAccessor.getIdentityAPI().addUserMembership(user.getId(), group.getId(), role.getId());
}
catch (Exception e){}
Hello,
i want to create in the same time the mail adresse of user thatway : After that the user complete de form i take his mail adresse and i create it exacly as i create a new profil with Login + PW as follow :
user.setFirstName(field_f_name3).setLastName(field_p_name3);
apiAccessor.getIdentityAPI().createUser(user);
But i dont know what code to write to fill the mail adresse as i did with Login and PassWord
It works thank you. But as you said he just create some user with username "toto", what if i want to create at the same time the password too ?!!
Hey,
I tried ur proposal but it doesn't works :/ .
I did this :
import org.bonitasoft.engine.identity.UserUpdater;
import java.util.logging.Logger;
Logger log = Logger.getLogger ("org.bonitasoft.hichem")
log.severe (" DEBUG - START changePw " )
final UserCreator user = new UserCreator ("toto", "toto");
apiAccessor.getIdentityAPI().createUser(user);
return true
Comments
I just tried your code and it worked fine on my side, a user with username "toto" was created. Did you have any errors? How do you know it didn't work? Can you log in as admin and go to the list of users to look for "toto" user? Note that your newly created user will have only username, and no first name nor last name (will be displayed as empty in the Portal).
Comments
Thanks it works :) .