Unity Connection JDBC-ODBC Bridge



Cisco SystemsUnity Connection JDBC-ODBC BridgeManualHoney Bhandari, Srushti Chaukhande3/31/2021Unity Connection’s JDBC port is not exposed to the public and restricted due to security reasons. However, Unity Connection has an alternate service, called the DB proxy service. By enabling this service, one can access the database through ODBC. This document will help you create the setup for a remote Java application to query content from Unity Connection using a JDBC-ODBC bridge.Contents TOC \o "1-3" \h \z \u Settings on Cisco Unity Connection PAGEREF _Toc61545067 \h 2Setting up Informix ODBC driver at the Client PAGEREF _Toc61545068 \h 4Creating ODBC datasource on client (Windows) PAGEREF _Toc61545069 \h 5Creating Secure ODBC datasource on client (Windows) PAGEREF _Toc61545070 \h 8Creating ODBC datasource on client (Linux) PAGEREF _Toc61545071 \h 14Using the datasource in the code PAGEREF _Toc61545072 \h 15Settings on Cisco Unity ConnectionLogin to the Cisco Unity Connection Administration.Search and edit the roles of the user required to be able to query the unity connection database remotely and update privileges with that of Remote Administrator.Edit the Web application password settings of this user to be like this:Go to System settings > Advanced > Connection administration and update “Database Proxy: Maximum Simultaneous Connections” to atleast 10. Max value is 999.Go to Cisco Unity Connection Serviceability. Open Tools > Service Management.Under Optional services, activate Connection Database Proxy service if not activated already.Setting up Informix ODBC driver at the ClientDownload and install Informix client SDK from . You need to select version 3.70 for installation. Select appropriate version depending on your client’s OS and if it is 32/64 bit.Installation guide is available in the package. Use that for proper installation.Restart if required.Note: In subsequent sections, the installation path for Informix client SDK is considered as “C:\Program Files (x86)\Informix Client-SDK”. This path can be different depending on where Informix Client-SDK is installed.Creating ODBC datasource on client (Windows)Go to Control Panel > Administrative Tools > Data Sources (ODBC)Go to System DSN tab and click on AddIn Genaral tab provide the datasource name, say InformixDSGo to the Connection tab and provide the following values:Host name is that of the unity connection server.User Id and Password are the credentials of the user which has the Remote Administrator role.Go to the Environment tab and update the locale values as:If the value is not updateable, just click ok and save the changes and open the DSN again and come back to this environment tab, the value should be updateable then.Go back to the Connection tab and test the connection. Save the datasource, it is ready for use.Creating Secure ODBC datasource on client (Windows)Go to path C:\Program Files (x86)\Informix Client-SDK\etc and create a file named “conssl.cfg”, or alternatively open notepad as administrator and add following lines and save at given path:SSL_KEYSTORE_FILE C:/Program Files (x86)/Informix Client-SDK/sslClient/client.kdbSSL_KEYSTORE_STH C:/Program Files (x86)/Informix Client-SDK/sslClient/client.sthCopy and paste server certificate HAProxy_truststore.pem at path C:\Program Files (x86)\Informix Client-SDK\etcOpen command prompt as administrator and run the following commands :cd C:\Program Files (x86)\Informix Client-SDK\etcgsk8capicmd -keydb -create -db client.kdb -type cmsgsk8capicmd -cert -add -db client.kdb -label certificate -file HAProxy_truststore.pem -format asciiGo to Control Panel > Administrative Tools > Data Sources (ODBC)Go to System DSN tab and click on AddIn Genaral tab provide the datasource name, say InformixDSGo to the Connection tab and provide the following values:Host name is that of the unity connection server, use IP if host name is not accepted.User Id and Password are the credentials of the user which has the Remote Administrator role.Go to the Environment tab and update the locale values as:If the value is not updateable, just click ok and save the changes and open the DSN again and come back to this environment tab, the value should be updateable then.Go back to the Connection tab and test the connection. Save the datasource, it is ready for use.NOTE: For Mutual Authentication, perform the following additional steps –Update the conssl.cfg file at path C:\Program Files (x86)\Informix Client-SDK\etc to include this line :SSL_KEYSTORE_LABEL localCAOpen command prompt as administrator and run :i. gsk8capicmd -cert -create -db client.kdb -dn "CN=selfsignedcert,O=altran,OU=cisco,L=gurgaon,ST=haryana,C=IN" -size 2048 -sigalg sha256 -expire 7300 -label localCA -default_cert yesii. gsk8capicmd -cert -extract -db client.kdb -label localCA -format ascii -target client.pemCopy client.pem from C:\Program Files (x86)\Informix Client-SDK\etc and and paste it locally.Navigate to Cisco Unity Connection’s Cisco Unified Operating System Administration page and click on Security drop down and goto Certificate ManagementClick on upload certificate/certificate chainSelect tomcat-trust as certificate purpose and upload client.pem saved earlier.Restart Cisco Tomcat Service using the CLI "utils service restart Cisco Tomcat" on all cluster nodes.The certificate should be visible in certificate list.Note: Secure ODBC connection to Cisco Unity Connection is supported on release 14 and onwards.Creating ODBC datasource on client (Linux)After the installation has been done, follow the below steps:export INFORMIXDIR={absolute path of install directory}export INFORMIXSERVER=ciscounityexport INFORMIXSQLHOSTS=$INFORMIXDIR/etc/sqlhostsCopy odbcinst.ini from $INFORMIXDIR/etc/ to /etc/ if not already there.If the file already exists, then append else update with the below:[ODBC]Trace = NoTraceFile = /tmp/sql.logForceTrace = NoPooling = No[ids]Driver={absolute path of install directory}/lib/cli/iclit09b.soSetup={absolute path of install directory}/lib/cli/iclit09b.soAPILevel=1ConnectFunctions=YYYDriverODBCVer=03.81FileUsage=0SQLLevel=1smProcessPerConnect=YThreading = 0Copy odbc.ini from $INFORMIXDIR/etc/ to /etc/ if not already there.If the file already exists, then append else update with the below:[InformixDS]Driver=idsDatabase=UnityDirDbDescription=Unity Connection DatabaselogonID={user with remote administrator role}pwd={password of user}Servername=ciscounityTrace=0TraceDLL=idmrs09a.soTraceFile=odbctrace.outInstallDir={absolute path of install directory}Translationdll={absolute path of install directory}/lib/esql/igo4a304.soDB_LOCALE=en_us.utf8CLIENT_LOCALE=en_us.utf8SERVER_LOCALE=en_us.utf8IFX_LOCK_MODE_WAIT=10Create a file by name sqlhosts at $INFORMIXDIR/etc/Update this file with the entry:ciscounity onsoctcp {IP address of Unity Connection Server} 20532export LD_PRELOAD=/usr/lib/libodbc.soDatasource is ready for use.Using the datasource in the codeJava ImplementationThe 2 important differences from a normal JDBC connection in Java from the way JDBC-ODBC connection is configured is: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");String sqlq = "jdbc:odbc:InformixDS";Note, that we use the name datasource name “InformixDS” as set during the DSN configuration. Below is a complete runnable program.package com.cisco.db.connect;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import java.util.ArrayList;import java.util.List;/** * @author hbhandar * */public class JdbcOdbcConnection {private static String sql = "select first 10 u.alias from vw_user u;";/** * @param args */public static void main(String[] args) {new JdbcOdbcConnection().getData(sql);}public void getData(String query) {Connection conn = null;ResultSet rs = null;Statement stmt = null;List<String> users = new ArrayList<String>();try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");String sqlq = "jdbc:odbc:InformixDS";conn = DriverManager.getConnection(sqlq);stmt = conn.createStatement();rs = stmt.executeQuery(sql);while (rs.next()) {users.add(rs.getString("alias"));}System.out.println("Total users found: " + users.size()+ ", Users: " + users.toString());} catch (Exception e) {e.printStackTrace();}}}.NET Implementation:Cisco Unity Connection .NET ODBC SDK is required to run program given below. Configure a new DSN for secure/non-secure access for example,“InformixDS” and substitute the name in code connection = new OdbcConnection("DSN=InformixDS");using System;using System.Data;using System.Data.Odbc;using Cisco.UnityConnection.OdbcSdk;namespace ConsoleApp5{ class Program { private static UnityConnectionServerOdbcSdk _cxn; static void Main() { _cxn = new UnityConnectionServerOdbcSdk("ConsoleAppp5"); OdbcConnection connection; try { Console.WriteLine("Logging in..."); connection = new OdbcConnection("DSN=InformixDS"); Console.WriteLine("Initially Connection state is : " + connection.State); connection.Open(); Console.WriteLine("Now Connection state is : " + connection.State); } catch (Exception ex) { Console.WriteLine($"Failed logging into server: {ex}"); Console.ReadLine(); return; } OdbcCommand command = connection.CreateCommand(); mandText = "SELECT Alias from vw_user"; OdbcDataReader dataReader = command.ExecuteReader(); int count = dataReader.FieldCount; Console.WriteLine("Printing DataReader"); for(int i=0; i<count; i++) { String str = dataReader.GetName(i); Console.Write(str); } Console.WriteLine(); while (dataReader.Read()) { for (int i = 0; i < count; i++) { String str = dataReader.GetString(i); Console.Write(str + ", "); } } Console.WriteLine(); dataReader.Close(); command.Dispose(); connection.Close(); Console.WriteLine("Now Connection state is : " + connection.State); Console.WriteLine("Complete."); Console.ReadLine(); } }} ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download