文档库 最新最全的文档下载
当前位置:文档库 › BlackBerry_Administration_API-Development_Guide-For VS -5.0.2-US

BlackBerry_Administration_API-Development_Guide-For VS -5.0.2-US

BlackBerry Administration API For Microsoft .NET Developers Version: 5.0 | Service Pack: 2 Development Guide

Published: 2010-06-16 SWDT666751-1132076-0616085957-001

Contents

1Specifying the Specified attribute (4)

2Using the code samples in Microsoft Visual C# (5)

3Opening a connection (6)

View the available locales (6)

Specify the authentication credentials (6)

4Handling errors (8)

Handle a single-object API error (8)

Handle a multi-object API error (9)

5Managing user accounts (12)

Search for a user account on the messaging server (12)

Search for user account IDs (13)

Create a user account (15)

Delete user accounts (17)

Change or view a user account's information (17)

Move user accounts to a different BlackBerry Enterprise Server (18)

Remove a software configuration from a user account (19)

6Managing groups (21)

Retrieve group IDs (21)

Assign user accounts to a group (21)

Remove user accounts from a group (22)

Move user accounts to a different group (23)

7Managing BlackBerry devices (24)

Retrieve a BlackBerry device object (24)

Retrieve a BlackBerry device ID (24)

Assign a password to a BlackBerry device (25)

Specify the owner information on a BlackBerry device (26)

Delete data and deactivate a BlackBerry device (26)

Resend the peer-to-peer encryption key to BlackBerry devices (27)

Resend service books to BlackBerry devices (28)

Search for user accounts that have a specific application on their BlackBerry devices (28)

View the last contact date for BlackBerry devices (30)

8Sending messages to BlackBerry devices (33)

Send a PIN message to BlackBerry devices (33)

Send an email message to BlackBerry devices (33)

9Managing policies (35)

Retrieve an IT policy ID (35)

Assign an IT policy to a user account (35)

Assign an IT policy to a group (36)

Search for an IT policy rule in an IT policy (36)

10Managing WLAN configurations (38)

Assign a WLAN configuration to a user account (38)

Remove a WLAN configuration from a user account (39)

Assign a VPN configuration to a user account (40)

Remove a VPN configuration from a user account (42)

11Managing BlackBerry Enterprise Server components (44)

Retrieve a service object (44)

Retrieve a service ID (44)

Retrieve a service instance ID (45)

Retrieve a service instance object (46)

Retrieve a host service instance object (47)

Retrieve a host service instance ID (48)

Retrieve a core service instance ID (49)

Retrieve a core service instance object (50)

12Managing message forwarding (52)

Turn on message forwarding for user accounts (52)

Turn off message forwarding for user accounts (53)

Change the folder settings for message forwarding for a BlackBerry device (53)

13Glossary (55)

14Provide feedback (56)

15Legal notice (57)

Development Guide Specifying the Specified attribute

Specifying the Specified attribute1 When you generate a client proxy by using wsdl.exe, wsdl.exe creates a Specified attribute on a class when wsdl.exe maps an optional property that is a primitive data type. Optional properties are defined in the XML schema with the minOccurs="0" parameter.

The wsdl.exe creates a Specified attribute for primitive types, such as enumeration, int, boolean or double, where an unspecified value for the optional property cannot be represented by a null value. The wsdl.exe does not create a

Specified attribute for true object references, where an unspecified value can be represented by a null value. If you specify a valid value for an optional property that is a primitive data type, you must set the

Specified boolean flag to true.

You can view the XML schema for any class in the API reference for the BlackBerry? Administration API.

Code sample: Using an optional property

In the following code sample, the sortBy property specifies the sort order for the findUsers method. The sortBy property is defined as optional in the XML schema for the FindUsers class, with the minOccurs="0" parameter. When you specify a value for the @enum property, you must set the enumSpecified attribute to true to notify the web server that you are using a valid value for this property.

BASUserSearchResultSortByEnum sortBy = new BASUserSearchResultSortByEnum();

sortBy.@enum = BASUserSearchResultSortByEnumType.DISPLAY_NAME;

sortBy.enumSpecified = true;

Code sample: Using a required property

In the following code sample, the authenticator ID field is used in the encodeUsername object to invoke the encodeUsername method. The identifier property is a primitive data type and it is defined as required in the XML schema for the EncodeUsername class, with the minOccurs="1" parameter. The property is required, and wsdl.exe does not create a corresponding identifierSpecified attribute. Therefore, you do not include an identifierSpecified=true statement when you create an instance of encodeUsername.

encodeUsername request = new encodeUsername();

request.identifier = authenticator.id;

4

Development Guide Using the code samples in Microsoft Visual C#

Using the code samples in Microsoft Visual C#2 After you install and configure your development environment, you can use the code samples in the BlackBerry? Administration API Development Guide to start building your applications.

Many code samples in the BlackBerry Administration API Development Guide use a string named locale. This string represents the region and language that you want your API request to apply to. For example, the string "en_US" represents the United States and the English language. To view all the locales available on your BlackBerry? Enterprise Server, you can use the findLocales() method in the utilws web service.

The code samples provided use the following web service instances:

?coreWebService

?dispatcherWebService

?emailDominoWebService

?emailExchangeWebService

?utilWebService

You can create instances only of the web services that you included when you generated the client proxy. You should not have multiple email web services. However, the methods in the email web services can be used interchangeably in most cases . Code sample: Creating a web service instance

The following code sample creates the coreWebService instance.

public static BAAServiceCore coreWebService = new BAAServiceCore();

coreWebService.Url = "https://" + basURL + "/baaws/core/ws?wsdl";

5

Development Guide Opening a connection

Opening a connection3

View the available locales

Many of the methods in the BlackBerry? Administration API require a locale parameter to identify the region and language for the data that your application sends or receives. You can use the findLocales() method to view all the locales that are available on your BlackBerry? Enterprise Server.

1.Invoke findLocales().

findLocales request = new findLocales();

String[] locales = utilWebService.findLocales(request);

2.Print the available locales.

for (int i =0; i < locales.Length; i++)

{

System.Console.WriteLine(locales[i])

}

Specify the authentication credentials

You can specify and store your authentication credentials using the utilws web service so that the credentials are sent automatically with each request to the BlackBerry? Administration API. To log in, you can use any of the authenticator methods supported by your BlackBerry Administration Service. For example, you can use the internal authenticator to log in using the user account credentials stored by the BlackBerry Administration Service, or you can use an external authenticator, such as Microsoft?Active Directory?.

Before you begin: Retrieve the following strings:

?userName string for the user account you want to use to log in to the BlackBerry Administration API

?password string for the user account you want to use to log in to the BlackBerry Administration API

1.Specify the encodeUsername() parameters.

The following code sample uses the internal authenticator. To use an external authenticator, use the

AUTHENTICATOR_TYPE_PLUG_IN enumeration and specify a string for the domain you want to use, and an integer for the identifier of the external authenticator. For example, for an Active Directory authenticator, specify the Active Directory domain name and the indentifer 111.To view the external authenticators available on your BlackBerry Administration Service, use the findAuthenticators() method in the utilws web service.

ExternalAuthenticatorTypesEnum authenticator = new ExternalAuthenticatorTypesEnum ();

authenticator.@enum =

ExternalAuthenticatorTypesEnumType.AUTHENTICATOR_TYPE_INTERNAL;

authenticator.enumSpecified = true;

encodeUsername encodeUsernameRequest = new encodeUsername();

6

Development Guide Specify the authentication credentials

encodeUsernameRequest.domain = null;

encodeUsernameRequest.type = authenticator;

encodeUsernameRequest.identifier = 0;

encodeUsernameRequest.credentialType = "0";

https://www.wendangku.net/doc/335741851.html,ername = userName;

2.Invoke encodeUsername().

encodeUsernameResponse encodeUsernameResponse = utilWebService.encodeUsername

(encodeUsernameRequest);

String encodedUser = encodeUsernameResponse.returnValue;

3.Store the encoded credentials in each web service that you use. You do not need to attach the credentials to the

utilws web service.

coreWebService.Credentials = new NetworkCredential(encodedUser, password);

coreWebService.PreAuthenticate = true;

dispatcherWebService.Credentials = new NetworkCredential(encodedUser, password);

dispatcherWebService.PreAuthenticate = true;

emailExchangeWebService.Credentials = new NetworkCredential(encodedUser,

password);

emailExchangeWebService.PreAuthenticate = true;

7

Development Guide Handling errors

Handling errors4

Handle a single-object API error

Single-object APIs use return objects that contain a return status object of the type ReturnStatus, where MethodName is the name of the API method that your application called. The following code sample shows how you can handle the single-object API errors in the createUser() method.

1.Invoke the single-object API and check to see if any errors occurred.

createUserResponse createUserResponse = coreWebService.createUser

(createUserRequest);

CreateUserResult createUserResult = createUserResponse.returnValue;

if (createUserResult.createUserReturnStatus.code !=

CreateUserReturnStatusEnumType.SUCCESS)

{

2.Verify that the error was not a server-side error. For example, the BlackBerry? Enterprise Server that hosts a component

you are trying to use is unavailable.

if (createUserResult.createUserReturnStatus.actor.ToUpper().Equals("SERVER")) {

//notify the user that the server cannot process the request

}

3.Depending on how much information or error handling you want to provide, perform one of the following actions:

a.To display the error description provided by the BlackBerry? Administration API, use the message attribute.

System.Console.WriteLine(createUserResult.createUserReturnStatus.message);

b.To display more detailed information or instructions to your user, check for each error code that is listed in the

ReturnStatusEnumType class in the API reference. For example, see the

CreateUserReturnStatusEnumType class in the API reference for a list of error codes in the createUser () method.

if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.UNKNOWN)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.NOT_AUTHORIZED)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.RESULT_ERROR_EXISTS)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

8

CreateUserReturnStatusEnumType.INVALID_PARAMETER)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.TARGET_SERVICE_INSTANCE_NOT_RUNNING)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

https://www.wendangku.net/doc/335741851.html,ER_ALREADY_BLACKBERRY_ENABLED)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.COULD_NOT_ENABLE_DELETE_BLACKBERRY_USER)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.CANNOT_ADD_USER_TO_GROUP)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.CANNOT_ATTACH_ITPOLICY_TO_USER)

{

// handle error

} else if (createUserResult.createUserReturnStatus.code ==

CreateUserReturnStatusEnumType.CANNOT_ATTACH_SOFTWARE_CONFIGURATION_TO_USER)

{

// handle error

}

4.Close the if statement.

}

Handle a multi-object API error

Multi-object APIs use return objects that contain an array of return status objects and a global return status object. The array of return status objects describes the errors that prevent individual objects from being processed. The global return status object describes the errors that prevent all objects from being processed. When you use multi-object APIs, your application should examine both the array of return status objects and the global return status object.

1.Invoke the multiple-object method and check the global return status object for errors.

createUserResponse createUserResponse = coreWebService.createUser

(createUserRequest);

CreateUserResult createUserResult = createUserResponse.returnValue;

if (createUserResult.createUserReturnStatus.code !=

CreateUserReturnStatusEnumType.SUCCESS)

{

2.Verify that the error is not a server-side error. For example, the BlackBerry? Enterprise Server that hosts a component you

are trying to use is unavailable.

9

if (createUserResult.createUserReturnStatus.actor.Equals("server") == "true") {

//notify the user that the server cannot process the request

}

3.Check the return status object for each user object.

for (int count=0; count

{

4.Depending on how much information or error handling you want to provide, perform one of the following actions:

a.To display the error description provided by the BlackBerry? Administration API, use the message attribute.

System.Console.WriteLine(createUserResult.createUserReturnStatus

[count].message);

b.To display more detailed information or instructions to your user, check for each error code listed in the

ReturnStatusEnumType class in the API reference. For example, see the

CreateUserReturnStatusEnumType class in the API reference for a list of of the error codes in the

createUser() method.

if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.UNKNOWN)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.NOT_AUTHORIZED)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.RESULT_ERROR_EXISTS)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.INVALID_PARAMETER)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.TARGET_SERVICE_INSTANCE_NOT_RUNNING)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

https://www.wendangku.net/doc/335741851.html,ER_ALREADY_BLACKBERRY_ENABLED)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.COULD_NOT_ENABLE_DELETE_BLACKBERRY_USER)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

10

CreateUserReturnStatusEnumType.CANNOT_ADD_USER_TO_GROUP)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.CANNOT_ATTACH_ITPOLICY_TO_USER)

{

// handle error

} else if (createUsersResult.createUserReturnStatus[count].code ==

CreateUserReturnStatusEnumType.CANNOT_ATTACH_SOFTWARE_CONFIGURATION_TO_USER)

{

// handle error

}

5.Close if and for statements.

}

}

11

Development Guide Managing user accounts

Managing user accounts5

Search for a user account on the messaging server

You can use any attribute in the MailStoreUserSearchCriteriaType class to search for user accounts on the messaging server . The findMailStoreUsers() method can return multiple results if the search criteria is not unique. The findMailStoreUsers() method adds wildcard characters to the beginning and end of all search terms. For example, if you search using an email address for the string https://www.wendangku.net/doc/335741851.html,mbier, the result could contain the user accounts for

https://www.wendangku.net/doc/335741851.html,mbier@https://www.wendangku.net/doc/335741851.html,, https://www.wendangku.net/doc/335741851.html,mbier2@https://www.wendangku.net/doc/335741851.html,, and

https://www.wendangku.net/doc/335741851.html,mbier@https://www.wendangku.net/doc/335741851.html,. The following code sample searches for a user account using a complete, unique email address in the search criteria.

Before you begin: Retrieve the emailAddress string for the user you want to find.

1.Create the search criteria. To search using more than one of the criteria in the

MailStoreUserSearchCriteriaType class, specify the additional criteria after the email address.

MailStoreUserSearchCriteria criteria = new MailStoreUserSearchCriteria();

criteria.emailAddress = emailAddress;

2.Specify the order that the BlackBerry? Administration API returns the results in. The following code sample assumes that

the search criteria is unique and only one result is returned, but you should always specify the order.

MailStoreUserSearchResultSortByEnum sortByEnum = new

MailStoreUserSearchResultSortByEnum();

sortByEnum.@enum = MailStoreUserSearchResultSortByEnumType.DISPLAY_NAME;

sortByEnum.enumSpecified = true;

3.Specify the page size and the locale.

int pageSize = 1;

String locale = "en_US";

4.Invoke findMailStoreUsers().

You use the pageCriteria parameter when multiple pages of results are returned. To change the number of results per page, use the pageSize parameter. If there are multiple pages of results, set the pageCriteria parameter to null to obtain the first page of the results. To retrieve the next page of results, invoke the findMailStoreUsers() method again and specify the last value in the results from the previous search as the pageCriteria parameter.

findMailStoreUsers findMailStoreUsersRequest = new findMailStoreUsers();

findMailStoreUsersRequest.searchCriteria = criteria;

findMailStoreUsersRequest.sortByCriteria = sortByEnum;

findMailStoreUsersRequest.sortByAscendingOrder = true;

findMailStoreUsersRequest.criteriaAndResultSetLocale = locale;

findMailStoreUsersRequest.pageCriteria = null;

findMailStoreUsersRequest.pageSize = pageSize;

12

FindMailStoreUsersResponse findMailStoreUsersResponse =

emailExchangeWebService.findMailStoreUsers(findMailStoreUsersRequest);

FindMailStoreUsersResult result = findMailStoreUsersResponse.returnValue;

5.Check the result for errors and handle any errors.

if ((result.findMailStoreUsersReturnStatus.code ==

FindMailStoreUsersReturnStatusEnumType.SUCCESS) &&

(result.mailStoreUserSearchResult.Length == 1))

{

return result.mailStoreUserSearchResult[0];

}

else

{

// handle any errors

}

Search for user account IDs

To search for user account IDs, you can use any search criteria in the classes that extend the UserSearchCriteriaServiceAttributesType class, such as device PIN using the BASUserSearchCriteriaServiceAttributesType class and email address in the EmailCommonUserSearchCriteriaServiceAttributesType class. The findUsers() method might return multiple users account IDs if the search criteria is not unique. The findUsers() method automatically adds wildcard characters to the beginning and end of each search term. For example, if you search for user accounts' BlackBerry? device PIN using the string "1", the BlackBerry? Administration API returns a result that contains all users with a BlackBerry device PIN that contains a one. The following code sample uses the user accounts' display names as the search criteria.

Before you begin:

Retrieve the userDisplayName string for the display name of the user you are trying to find.

1.Specify the search criteria using the displayName attribute in the

BASUserSearchCriteriaServiceAttributesType class.

To specify the search criteria, you can use any of the classes that extend the

UserSearchCriteriaServiceAttributesType class. Each class that extends the

UserSearchCriteriaServiceAttributesType class contains additional search criteria that you can specify for your search. The number of search criteria that are available to you depends on the components that are installed on your BlackBerry? Enterprise Server. For more information about the available search criteria, see the

UserSearchCriteriaServiceAttributesType class in the API reference.

UserSearchCriteria searchCriteria = new UserSearchCriteria();

BASUserSearchCriteriaServiceAttributes basServiceAttributes = new

BASUserSearchCriteriaServiceAttributes();

basServiceAttributes.displayName = userDisplayName;

https://www.wendangku.net/doc/335741851.html,erSearchCriteriaServiceAttributes = new

UserSearchCriteriaServiceAttributesType[1];

https://www.wendangku.net/doc/335741851.html,erSearchCriteriaServiceAttributes[0] = basServiceAttributes;

13

2.Specify the order that you want the results returned in.

BASUserSearchResultSortByEnum sortBy = new BASUserSearchResultSortByEnum();

sortBy.@enum = BASUserSearchResultSortByEnumType.DISPLAY_NAME;

sortBy.enumSpecified = true;

findUsersRequest.sortBy = sortBy;

findUsersRequest.sortAscendingOrder = true;

3.Specify the maximum number of results returned for each page, the locale, and the last result element. For your first search

request, assign a null value for the last result element.

FindUsers findUsersRequest = new FindUsers();

findUsersRequest.locale.pageSize = 3;

https://www.wendangku.net/doc/335741851.html,stResultElement = null;

findUsersRequest.locale = locale;

findUsersRequest.searchCriteria = searchCriteria;

4.Invoke findUsers().

findUsersResponse response = coreWebService.findUsers(findUsersRequest);

findUsersResult result = response.returnValue;

5.Check the result for errors and handle any errors.

if (result.findUsersReturnStatus.code != FindUsersReturnStatusEnumType.SUCCESS) {

// handle any errors

}

6.Loop through the search results to get the ID of each user who matches the search criteria. To retrieve the page of results,

specify the last result element from the previous findUsers() request and invoke findUsers() again.

while (https://www.wendangku.net/doc/335741851.html,erSearchResult != null && https://www.wendangku.net/doc/335741851.html,erSearchResult!=null)

{

for (int i = 0; i < https://www.wendangku.net/doc/335741851.html,erSearchResult.Length; i++)

{

UserSearchResult searchResult = https://www.wendangku.net/doc/335741851.html,erSearchResult[i];

UserSearchResultServiceAttributesType[] serviceAttributes =

https://www.wendangku.net/doc/335741851.html,erSearchResultServiceAttributes;

for (int j = 0; j < serviceAttributes.Length; j++)

{

if (serviceAttributes[j].GetType().Equals(typeof

(BASUserSearchResultServiceAttributes)))

{

BASUserSearchResultServiceAttributesType BASAttributes =

serviceAttributes[j] as BASUserSearchResultServiceAttributesType;

String currentUserID = https://www.wendangku.net/doc/335741851.html,erId;

// Do something with the user ID here.

}

}

}

lastResultElement = https://www.wendangku.net/doc/335741851.html,erSearchResult

14

[https://www.wendangku.net/doc/335741851.html,erSearchResult.Length - 1];

https://www.wendangku.net/doc/335741851.html,stResultElement = lastResultElement;

response = coreWebService.findUsers(findUsersRequest);

result = response.returnValue;

}

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.

15

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;

https://www.wendangku.net/doc/335741851.html,anizationId = 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();

https://www.wendangku.net/doc/335741851.html,erEnableBlackBerryAttributes = userEnableBBAttributes;

createUserRequest.locale = locale;

createUserRequest.group = 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

}

16

Delete user accounts

You can delete multiple user accounts on the BlackBerry? Enterprise Server using the deleteUsers() method. To delete one user account, you can use the deleteUser() method instead.

Before you begin: Retrieve the userIDs integer array for the IDs of the user accounts that you want to delete.

1.Invoke deleteUsers().

deleteUsers deleteRequest = new deleteUsers();

https://www.wendangku.net/doc/335741851.html,erIds = userIDs;

deleteUsersResponse deleteResponse = coreWebService.deleteUsers(deleteRequest);

DeleteUsersResult result = deleteResponse.returnValue;

2.Check the result for errors and handle any errors.

if(result.deleteUsersReturnStatus.code !=

DeleteUserReturnStatusEnumType.SUCCESS )

{

// handle any errors

}

Change or view a user account's information

You can retrieve a user account using the getUser() method and change or view the attributes of the user account object. The following code sample changes the user account's display name and retrieves the WLAN configuration for the user account, if a WLAN configuration is assigned.

Before you begin: Retrieve the following variables:

?userID integer for the ID of the user account that you want to access

?newDisplayName string for the value you want to change the user account's display name to

.

1.Specify the getUser() parameters, including whether to load each of the classes that the user acccount's information is

stored in. The following code sample uses the displayName attribute in the UserServiceAttributes class and the policyName attribute in the UserWLANVPNVOIPConfigurations class so it loads only those two classes.

String wlanConfig;

getUser getUserRequest = new getUser();

https://www.wendangku.net/doc/335741851.html,erId = userID;

getUserRequest.locale = locale;

getUserRequest.loadUserServiceAttributes = true;

getUserRequest.loadUserDeviceConfigurationServiceAttributes = false;

getUserRequest.loadUserResolvedGroups = false;

getUserRequest.loadUserResolvedGroupIds = false;

getUserRequest.loadUserGroups = false;

getUserRequest.loadUserWLANVPNVOIPConfigurations=true;

17

Development Guide Move user accounts to a different BlackBerry Enterprise Server

2.Invoke getUser() to retrieve the user account object.

GetUserResponse response = coreWebService.getUser(getUserRequest);

GetUserResult result = response.returnValue;

3.Check the result for errors and handle any errors.

if (result.getUserReturnStatus.code != GetUserReturnStatusEnumType.SUCCESS)

{

// handle any errors

}

4.Change the display name and check for any errors.

User user = https://www.wendangku.net/doc/335741851.html,er;

user.displayName = newDisplayName;

setUser setUserRequest = new setUser();

setUserRequest.locale = locale;

https://www.wendangku.net/doc/335741851.html,er = user;

SetUserResult setUserResult=coreWebService.setUser(setUserRequest).returnValue;

if (setUserResult.setUserReturnStatus.code !=

SetUserReturnStatusEnumType.SUCCESS)

{

// handle any errors

}

5.Retrieve the WLAN configurations that are assigned to this user account.

for (int i = 0; i < user.ITPolicyWLANVPNVOIPAttributes.Length; i++)

{

if( user.ITPolicyWLANVOIPAttributes[i].GetType().Equals(typeof

(WLANConfigurations)))

{

wlanConfig = user.ITPolicyWLANVOIPAttributes[i].policyName;

// do something with policyName here.

}

}

Move user accounts to a different BlackBerry Enterprise Server

You can use the moveUsers() method to move a user from one BlackBerry? Enterprise Server to another in your BlackBerry Domain. If you are only moving one user account, you can use the moveUser() method in a similar manner.

Before you begin: Obtain the following objects and attributes:

?The user account IDs userIDs of the users you want to move

?The dispatcher host service instance targetDispatcherInstance that you want to move the users to

1.Create the UserMoveBlackBerryAttributes object that is required as a parameter of moveUsers().

18

相关文档