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
- Invoke gatherEnableBlackBerryUserAttributes().
GatherEnableBlackBerryUserAttributesResult attributes = emailExchangeWebService.gatherEnableBlackBerryUserAttributes(userAccount, locale);
- Check the result for errors and handle any errors.
if (attributes.gatherEnableBlackBerryUserAttributesReturnStatus().getCode() != GatherEnableBlackBerryUserAttributesReturnStatusEnumType.SUCCESS)
{
//handle any errors
}
- 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);
}
- 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);
- Specify values for the UserEnableBlackBerryAttributes
flags.
userEnableBBAttributes.setIgnoreDuplicateWarning(false);
userEnableBBAttributes.setIgnoreEncryptionWarning(false);
userEnableBBAttributes.setIgnoreInactiveTargetWarnings(false);
userEnableBBAttributes.setFailOutstandingJobs(false);
userEnableBBAttributes.setOrganizationId(0);
- 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;
- Invoke createUser().
CreateUserResult createUserResult = coreWebService.createUser(userEnableBBAttributes, locale, targetGroup, targetITPolicy, targetSoftwareConfiguration);
if (createUserResult.getCreateUserReturnStatus().getCode() != CreateUserReturnStatusEnumType.SUCCESS)
- 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.