How can i create a user and make him a member of a group automaticly

1
0
-1

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 ,

1 answer

1
+1
-1
This one is the BEST answer!

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/engin...(java.lang.String, java.lang.String, java.lang.String, java.lang.String) [here]: http://documentation.bonitasoft.com/javadoc/api/6.3/org/bonitasoft/engin...(long, long, long)

Comments

Submitted by wannes.fedi on Sun, 04/26/2015 - 09:59

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

Submitted by Sean McP on Sun, 04/26/2015 - 10:22

Getting the grouppath is done through the organization, if using Community I do this as follows:

//get all the groups
List<Group> 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

Submitted by wannes.fedi on Sun, 04/26/2015 - 10:46

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,

Submitted by Sean McP on Sun, 04/26/2015 - 12:09

So what I think you're asking is

  1. User opens a web page (any web page but one not in Bonita, or one that requires NO Authorization))
  2. User Fills in the details
  3. User Clicks submit
  4. 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

Submitted by wannes.fedi on Sun, 04/26/2015 - 13:12

thanks a lot sean that's really helps me

Notifications