Retrieve an instance of the Contacts API from the Client Session object using:
var contacts = clientSession.createContacts();
To check if the contacts service is available for search features use the following method. The availability of the contacts service is also reported via the onContactsAvailable and onContactsUnavailable events.
contacts.isContactsServiceAvailable();
Search the enterprise directory (LDAP) for contacts. This method should only be executed if the connection to the contacts service is available, otherwise the search will fail and be reported via the onContactsSearchFailed event. Results are returned asynchronously via the onContactsSearchCompleted event.
var searchRequest = contacts.search(searchString, maxResults);
To cancels the currently active search use the following method.
contacts.cancelSearch();
As API requests are asynchronous, it is necessary to create callbacks to listen out for events triggered. For more information on events see the API reference documentation.
contacts.addOnContactsAvailableCallback(callback);
contacts.addOnContactsUnavailableCallback(callback);
contacts.addOnContactsSearchResultsUpdatedCallback(callback);
contacts.addOnContactsSearchFailedCallback(callback);
contacts.addOnContactsSearchCompletedCallback(callback);