BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 09-10-2009, 08:35 AM   #1 (permalink)
New Member
Join Date: Jun 2009
Model: 8330
Carrier: None
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with 5.0 Admin api

Please Login to Remove!


Has anybody used bkackberry admin api. What Iam looking for is to find deviceid for user given a userid, rather i should say display name. There is a method called findDeviceforUser in core Ws but that needs an userid, an integer. And to get the userid , there is method called findUsers where you can use displayName to get the userid. This all looks simple

But the problem is the code sample snippets given in the document have all mistakes. First I have created the javaproxy with wsdl2java by passing core ws wsdl. 1) From then its not clear how to use proxy code 2) then sample snippet of code given for findUsers and findDeviceForuser code is not correct

I need some immediate help on this. Please let me know. Iam looking
1) how to use proxy client after generating the code with wsdl2java
2) using findUsers and findDeviceforUser . Code samples will be of great help

Thank You
Old 09-16-2009, 08:22 AM   #2 (permalink)
Thumbs Must Hurt
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Post Thanks: 0
Thanked 0 Times in 0 Posts


Here's a demo app I created from the sample apps that prompts for a user name, and message to send.


public partial class Form1 : Form
	public static BAAServiceCore coreWebService = new BAAServiceCore();
	public static BAAServiceUtil utilWebService = new BAAServiceUtil();
	public static BAAServiceEmailExchange emailExchangeWebService = new BAAServiceEmailExchange();
	public static BAAServiceDispatcher dispatcherWebService = new BAAServiceDispatcher();

	private string basURL = "";
	private string userName = "XXXXX";
	private string password = "XXXXXXXX";
	private int[] userIDs;

	public Form1()

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

		encodeUsername encodeUsernameRequest = new encodeUsername();
		encodeUsernameRequest.username = userName;
		encodeUsernameResponse encodeUsernameResponse = utilWebService.encodeUsername(encodeUsernameRequest);
		String encodedUser = encodeUsernameResponse.returnValue;

		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;

	private void btnSend_Click(object sender, EventArgs e)

		sendPIN("Testing", txtMsg.Text);


	private void findUserID(string userDisplayName)
		findUsers findUsersRequest = new findUsers();
		UserSearchResult lastResultElement = null;
		UserSearchCriteria searchCriteria = new UserSearchCriteria();
		BASUserSearchCriteriaServiceAttributes basServiceAttributes = new BASUserSearchCriteriaServiceAttributes();

		basServiceAttributes.displayName = userDisplayName;
		searchCriteria.userSearchCriteriaServiceAttributes = new UserSearchCriteriaServiceAttributesType[1];
		searchCriteria.userSearchCriteriaServiceAttributes[0] = basServiceAttributes;
		findUsersRequest.searchCriteria = searchCriteria;

		findUsersRequest.pageSize = 3;
		findUsersRequest.locale = "en_US";

		BASUserSearchResultSortByEnum sortBy = new BASUserSearchResultSortByEnum();
		sortBy.@enum = BASUserSearchResultSortByEnumType.DISPLAY_NAME;
		sortBy.enumSpecified = true;
		findUsersRequest.sortBy = sortBy;
		findUsersRequest.sortAscendingOrder = true;

		findUsersResponse response = coreWebService.findUsers(findUsersRequest);

		if (response.returnValue.findUsersReturnStatus.code != FindUsersReturnStatusEnumType.SUCCESS)
			// handle any errors
			string dbg = "here";

		userIDs = new int[response.returnValue.userSearchResult.Length];
		while (response.returnValue.userSearchResult != null && response.returnValue.userSearchResult != null)
			for (int i = 0; i < response.returnValue.userSearchResult.Length; i++)
				UserSearchResult searchResult = response.returnValue.userSearchResult[i];
				UserSearchResultServiceAttributesType[] serviceAttributes = searchResult.userSearchResultServiceAttributes;
				for (int j = 0; j < serviceAttributes.Length; j++)
					if (serviceAttributes[j].GetType().Equals(typeof (BASUserSearchResultServiceAttributes)))
						BASUserSearchResultServiceAttributesType BASAttributes =
						serviceAttributes[j] as BASUserSearchResultServiceAttributesType;
						userIDs[i] = BASAttributes.userId;
			lastResultElement = response.returnValue.userSearchResult[response.returnValue.userSearchResult.Length - 1];
			findUsersRequest.lastResultElement = lastResultElement;

			response = coreWebService.findUsers(findUsersRequest);

	private void sendPIN(string messageSubject, string messageBody)
		sendMessageToUsers request = new sendMessageToUsers();
		sendMessageToUsersResponse response;
		UserMessage message = new UserMessage();
		message.subject = messageSubject;
		message.body = messageBody;

		DispatcherMessageTypeEnum messageType = new DispatcherMessageTypeEnum();
		messageType.@enum = DispatcherMessageTypeEnumType.PIN;
		messageType.enumSpecified = true;

		request.userIds = userIDs;
		request.message = message;
		request.messageTypeEnum = messageType;

		response = coreWebService.sendMessageToUsers(request);

		if (response.returnValue.sendMessageToUsersReturnStatus.code != SendMessageToUserReturnStatusEnumType.SUCCESS)
			// handle any errors
			string dbg = "here";
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Extron RGB 202xi ADSP Universal Analog, ECL and TTL Computer-Video Interface
Extron RGB 202xi ADSP Universal Analog, ECL and TTL Computer-Video Interface pictureMeasurement Computing PCI-DAS1602/16 Analog and Digital I/O Board
Measurement Computing PCI-DAS1602/16 Analog and Digital I/O Board pictureExtron RGB-190F Universal Analog Computer-Video Interface
Extron RGB-190F Universal Analog Computer-Video Interface pictureExtron RGB 109xi VGA Computer Audio Video Analog Interface with ADSP
Extron RGB 109xi VGA Computer Audio Video Analog Interface with ADSP pictureMEASUREMENT COMPUTING ANALOG & DIGITAL I/O DAQ PCI BOARD PCIM-DAS1602/16

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.