Create users

Hey,

Is it possible to create users with a form ? (Not in the portal). I tried to do that with some groovy code, like :

import org.bonitasoft.engine.api.APIAccessor; import org.bonitasoft.engine.api.impl.transaction.identity.GetRole; import org.bonitasoft.engine.exception.UpdateException; import org.bonitasoft.engine.identity.UserCreator; import org.bonitasoft.engine.identity.UserUpdater; import org.bonitasoft.engine.identity.impl.UserMembershipImpl;

import java.util.logging.Logger;

Logger log = Logger.getLogger (“org.bonitasoft.hichem”)
log.severe (" DEBUG - START creation " )

try{
final UserCreator createUser = new UserCreator(field_login1, field_pw1);
log.severe (" DEBUG - END creation " )
return true
} catch ( UpdateException e){
log.severe (" DEBUG - UpdateException : " + e.detailMessage )
log.severe (" DEBUG - END creation " )
return false
}

But it does not works ?!!! Thanks

HIi,

this my scritp, this running !!

 

import org.bonitasoft.engine.identity.ContactDataCreator

import org.bonitasoft.engine.api.APIClient
import org.bonitasoft.engine.api.IdentityAPI
import org.bonitasoft.engine.identity.User
import org.bonitasoft.engine.identity.UserCreator
import org.bonitasoft.engine.identity.UserMembership
import org.bonitasoft.engine.profile.Profile
import org.bonitasoft.engine.profile.ProfileMemberCreator
import org.bonitasoft.engine.search.SearchOptionsBuilder
import org.bonitasoft.engine.search.SearchResult
import org.bonitasoft.engine.session.APISession
import org.bonitasoft.engine.identity.UserSearchDescriptor
import org.bonitasoft.engine.api.*
import org.bonitasoft.engine.api.permission.APICallContext
import org.bonitasoft.engine.api.permission.PermissionRule
import org.bonitasoft.engine.profile.ProfileSearchDescriptor


def processAPI = apiAccessor.getProcessAPI()
def identityAPI = apiAccessor.getIdentityAPI()

LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();

UserCreator creator = new UserCreator(userLogin, userPassword)
creator.setFirstName(userFirstName).setLastName(userSecondName)
ContactDataCreator proContactDataCreator = new ContactDataCreator().setCity(cidade).setEmail(email);
creator.setProfessionalContactData(proContactDataCreator)
final User user = identityAPI.createUser(creator)

 

Hi,

As far as I know it is possible using the identity API. You can use-

  • POST - Create a user
  • GET - Read a user details or search for a group of users
  • PUT - Update a user
  • DELETE - Remove a user

You can read about it here in details: https://documentation.bonitasoft.com/bonita/2021.2/api/identity-api#_user

Let me know if it helps :)

Regards,

Soham