Enterprise Instant Messaging (Microsoft Unified Communications , IBM Sametime, Jabber)

Comprehensive Instant Messaging information resource for enterprise IT professionals
posts - 94, comments - 0, trackbacks - 0

Searching users using RTC 1.3 API (VB.NET)

This article demonstrates the process of searching users using RTC 1.3 API
Step1: Add reference to RTC 1.3 API in your project

Step2: Login to the LCS server using RTC API. For step by step process refer the article: Login process using RTC 1.3 API (VB.NET)
Step3: Add the following function to perform search
Public Sub PerformUserSearch(ByVal fullname As String, domain As String)
     'Send GivenName as blank to get all the users
     Dim IRTCUserSearch As IRTCUserSearch
     Dim IRTCUserSearchQuery As IRTCUserSearchQuery
     Set IRTCUserSearch = _IRTCClient2
     Set IRTCUserSearchQuery = IRTCUserSearch.CreateQuery
     'Add search term to Query
     IRTCUserSearchQuery.SearchTerm("name") = fullname
     'Set max. time (should be from 1-30 sec)
     IRTCUserSearchQuery.SearchPreference(RTCUSP_TIME_LIMIT) = 30
     'Set number of results to be returned (should be from 1-1000)
     IRTCUserSearchQuery.SearchPreference(RTCUSP_MAX_MATCHES) = 50
     'Set Domain Name
     IRTCUserSearchQuery.SearchDomain = domain
     'Execute Query
     Call IRTCUserSearch.ExecuteSearch(IRTCUserSearchQuery, _IRTCProfile2, lngFlag)
End Sub

Step4: After executing the search query, wait for Event Type RTCE_USERSEARCH in the RTCClient event callback sub routine
Step5: Add the following function to process search results received in RTCE_USERSEARCH event
Private Sub UserSearchResultsEvent(ByVal pEvent As RTCCORELib.IRTCUserSearchResultsEvent)
     'Called when Server returns Search Results
     Dim irtcCollection As RTCCORELib.IRTCCollection
     Dim Result As RTCCORELib.IRTCUserSearchResult
     Dim lng As Long
     Set irtcCollection = pEvent.Results
     For lng = 1 To irtcCollection.Count
         Set Result = irtcCollection.Item(lng)
         Debug.Write Result.Value(RTCUSC_URI)
End Sub

Print | posted on Tuesday, June 05, 2007 6:28 PM |