I want to create users with some groovy code. I tried with :
final UserCreator user = new UserCreator ("toto", "toto");But it doesn’t works !?
Thx
I want to create users with some groovy code. I tried with :
final UserCreator user = new UserCreator ("toto", "toto");But it doesn’t works !?
Thx
Try to add this line after the UserCreator that you prepare:
apiAccessor.getIdentityAPI().createUser(user);
Hey,
I tried ur proposal but it doesn’t works .
I did this :
import org.bonitasoft.engine.identity.UserCreator; 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
Can you write me the all code here please because now it said : “Error while submitting the form”. I think i have some error in my code.
And what i want, is just to create some user whith his password .
Thanks
It works now thank you. But as you said he just create some user with Login “toto”. What if i want to create even the passweord at the same time ?
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 ?!!
And to map the user to some profile , have i to do it with code or in the portal with administrator role ?
Yeah, i found this :
addUser(String username,
String password,
String firstName,
String lastName,
String title,
String jobTitle,
String managerUserUUID,
Map<String,String> profileMetadata)
But actualy i dont know what package and what parameters i should put ?!!
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 :
final UserCreator user = new UserCreator (field_u_login3, field_u_pw3);
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
Hi.
If you want to create a user with an email you can do this :
import org.bonitasoft.engine.identity.ContactDataCreator;
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
I tried to get the user Pass Word with this code but it doesn’t works :
return BonitaUsers.getProcessInstanceInitiator(apiAccessor, processInstanceId).getPassword();
?!!
The getPassword() method is deprecated. It always return null.
I think there is no method to get the password in 6.3.X version.
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).
The user will also have the password “toto”. What you need to more is to map this new user to some profile, for example User profile. It is only then that he would be able to log in to the Portal.
You should be able to do it through APi, have a look at the ProfileAPI here , I think that the correct method would be createProfileMember.
With the createProfileMember method you think that we can attribute a privilege (Administrator or user) to be able to connect on the portal ?
Found it
apiAccessor.getProfileAPI().createProfileMember(2, user.getId(), group.getId(), role.getId())1 : For the simple user
2 : For Administrator
You can make some combobox with the two choices and an IF…ELSE test before this line to attribute the right number
Thanks it works .
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){}