Create a user account

You create user accounts on the BlackBerry® Enterprise Server that are associated with corresponding user accounts on the messaging server. To create a user account, you use the corews web service and one of the email web services. The following code samples use the emailexchangews web service used with Microsoft® Exchange.
Before you begin:
Obtain the following data objects and variables:
  • userAccount search result for the user account on the messaging server.
  • dispatcherHostService integer for the host service instance ID of the BlackBerry Dispatcher that you want to add the user account to
  • to assign the user account to a group, group object for the group you want to assign the user account to
  • to assign a software configuration to the user account, softwareConfig object for the software configuration you want to assign to the user account
  • to assign an IT policy to the user, itPolicy object for the IT policy you want to assign to the user account
  1. Invoke gatherEnableBlackBerryUserAttributes().
    GatherEnableBlackBerryUserAttributesResult attributes = emailExchangeWebService.gatherEnableBlackBerryUserAttributes(userAccount, locale);
  2. Check the result for errors and handle any errors.
    if (attributes.gatherEnableBlackBerryUserAttributesReturnStatus().getCode() != GatherEnableBlackBerryUserAttributesReturnStatusEnumType.SUCCESS)
    {
       //handle any errors
    }
  3. Copy the attributes in the gatherEnableBlackBerryUserAttributes result to an EnableBlackBerryUserAttributes object. Use the UserEnableBlackBerryAttributes object to associate the user account with the corresponding account on the messaging server.
    UserEnableBlackBerryAttributes userEnableBBAttributes=new UserEnableBlackBerryAttributes();        
    for (EnableBlackBerryUserAttributesType itr:attributes.getEnableBlackBerryUserAttributes()) 
    {            
       userEnableBBAttributes.getEnableBlackBerryUserAttributes().add(itr);        
    }
  4. Specify the BlackBerry Dispatcher that you want to add the user account to as both the serviceInstance and the targetServiceInstance attributes of the UserEnableBlackBerryAttributes object .
    userEnableBBAttributes.setServiceInstance(dispatcherHostService);  
    userEnableBBAttributes.setTargetServiceInstance(dispatcherHostService);
  5. Specify values for the UserEnableBlackBerryAttributes flags.
    userEnableBBAttributes.setIgnoreDuplicateWarning(false);        
    userEnableBBAttributes.setIgnoreEncryptionWarning(false);
    userEnableBBAttributes.setIgnoreInactiveTargetWarnings(false);
    userEnableBBAttributes.setFailOutstandingJobs(false);
    userEnableBBAttributes.setOrganizationId(0);
  6. Specify the user account attributes. If you do not want to assign a group, IT policy, or software configuration to the user account, set these values to null.
    Group targetGroup = group;
    ITPolicy targetITPolicy = itPolicy;
    SofwareConfiguration targetSoftwareConfiguration = softwareConfig;
  7. Invoke createUser().
    CreateUserResult createUserResult = coreWebService.createUser(userEnableBBAttributes, locale, targetGroup, targetITPolicy, targetSoftwareConfiguration);
    if (createUserResult.getCreateUserReturnStatus().getCode() != CreateUserReturnStatusEnumType.SUCCESS)
  8. Check the result for errors and handle any errors.
    if (createUserResult.getCreateUserReturnStatus().getCode()!= CreateUserReturnStatusEnumType.SUCCESS) 
    {           
       // handle any errors                 
    }

Was this information helpful? Send us your comments.