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().
    gatherEnableBlackBerryUserAttributes gatherAttributes = new gatherEnableBlackBerryUserAttributes();
    gatherAttributes.result = userAccount;
    gatherAttributes.locale = locale;
    gatherEnableBlackBerryUserAttributesResponse AttributesResponse = emailExchangeWebService.gatherEnableBlackBerryUserAttributes(gatherAttributes);
    GatherEnableBlackBerryUserAttributesResult attributes = AttributesResponse.returnValue;
  2. Check the result for errors and handle any errors.
    if (attributes.gatherEnableBlackBerryUserAttributesReturnStatus.code != 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();
    userEnableBBAttributes.enableBlackBerryUserAttributes = new EnableBlackBerryUserAttributesType[attributesResult.enableBlackBerryUserAttributes.Length];
    for (int j = 0; j < attributes.enableBlackBerryUserAttributes.Length; j++)
       userEnableBBAttributes.enableBlackBerryUserAttributes[j] = attributes.enableBlackBerryUserAttributes[j];
  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.serviceInstance = dispatcherHostService;
    userEnableBBAttributes.targetServiceInstance = dispatcherHostService;
  5. Specify values for the UserEnableBlackBerryAttributes flags.
    userEnableBBAttributes.ignoreDuplicateWarning = false;
    userEnableBBAttributes.ignoreDuplicateWarningSpecified = true;
    userEnableBBAttributes.ignoreEncryptionWarning = false;
    userEnableBBAttributes.ignoreEncryptionWarningSpecified = true;
    userEnableBBAttributes.ignoreInactiveTargetWarnings = false;
    userEnableBBAttributes.ignoreInactiveTargetWarningsSpecified = true;
    userEnableBBAttributes.failOutstandingJobs = false;
    userEnableBBAttributes.organizationId = 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.
    createUser createUserRequest = new createUser();
    createUserRequest.userEnableBlackBerryAttributes = userEnableBBAttributes;
    createUserRequest.locale = locale; = group;
    createUserRequest.itpolicy = itPolicy;
    createUserRequest.softwareConfiguration = softwareConfig;
  7. Invoke createUser().
    createUserResponse createUserResponse = coreWebService.createUser(createUserRequest);
    CreateUserResult createUserResult = createUserResponse.returnValue;
  8. Check the result for errors and handle any errors.
    if (createUserResult.createUserReturnStatus.code != CreateUserReturnStatusEnumType.SUCCESS)
       // handle any errors

Was this information helpful? Send us your comments.