Hello ,
i’m a beginner in bonitasoft, and i’m looking for the solution to create new users using a form which is with a anonymous authentication, after that the user is created in the organisation and have the role of member of a group specified in the form . and the script of the creation of the new user is used in a script task , or i have to make two tasks the first is human and the second is a script task , I dont wanna make this manually with Organisation > Users and manage.
best regards ,
You will have to use the IdentityAPI and MembershipAPI
for example
createUser
User createUser(String userName,
String password,
String firstName,
String lastName)
throws AlreadyExistsException,
CreationException
Will create the user (see documentataion here: [createUser], and to add the user to a group see [here] .
Something like:
import IdentlyAPI; import MembershipAPI;def userName = “john.smith”
def defaultpwd = “bpm”
def firstName = “John”;
def lastName = “Smith”
def userGroup = group(“groupPath”).getid()
def userID = createUser(userName, defaultpwd, firstName, lastName)
def groupID = addMembership(userId, userGroup, roleId)
NOTE: This is sample pseudo code, you will need to complete it to get it to work. I’ve not done this before, just pointing you in the right direction.
In fact you could also look at the documentation here to see how it is really done in a process.
[http://documentation.bonitasoft.com/create-new-user]
[http://documentation.bonitasoft.com/add-user-group]
regards
[createUser]: http://documentation.bonitasoft.com/javadoc/api/6.3/org/bonitasoft/engine/api/UserAPI.html#createUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
[here]: http://documentation.bonitasoft.com/javadoc/api/6.3/org/bonitasoft/engine/api/MembershipAPI.html#addUserMembership(long, long, long)
[http://documentation.bonitasoft.com/create-new-user]: http://documentation.bonitasoft.com/create-new-user
[http://documentation.bonitasoft.com/add-user-group]: http://documentation.bonitasoft.com/add-user-group
Thanks a lot sean , just i want to know about the
def userGroup = group(“groupPath”).getid()
“groupPath” how can i find the path of a group
Getting the grouppath is done through the organization, if using Community I do this as follows:
//get all the groups
List groupList = apiAccessor.getIdentityAPI().getGroups(0, 2000, GroupCriterion.NAME_ASC);
for (Group group : groupList) {
String orgPath = group.getPath();
String delimiter = "/";
String[] temp;
temp = orgPath.split(delimiter);
organization = temp[1];
//then process the organization path as required…
}
regards
thanks a lot sean thats really helps me . but i’m beginner in bonitasoft community so i want to ask you if i have to create this code in a script task . and adding the variables such as the username , password, group path,… in the groovy script ? cause i want to authentificate with anonymous login and in the form i have to complete those fields after that the user is created in the group or subgroup specified
i really appreciate your answers mr sean thanks a lot
regards,
So what I think you’re asking is
- User opens a web page (any web page but one not in Bonita, or one that requires NO Authorization))
- User Fills in the details
- User Clicks submit
- The system automatically defines the User in Bonita so they can then use the system.
If so then, my big concern is security. Allowing people to assign their own logins not generally a good idea. However if it is really secure then OK.
I would do it this way.
Create a HTML page that people can go to
Add JavaScript etc to call REST and add the user that way
See REST here and REST Identity API here
I can’t help you further than that as I don’t really do REST, but that’s the way I would do it,
hope it gets you on your way,
regards
Seán
thanks a lot sean that’s really helps me