HOWTO: Connecting to a Lotus Notes / Domino application using ODBC and Linked Server

HOWTO: Connecting to a Lotus Notes / Domino application using ODBC and Linked Server

  
Recently I've come accross a few customers that were looking into ways to integrate new OutSystems applications with existing data from legacy Lotus Notes / Domino applications that were still being used.

Two options came up as the most promising ones
  • Using Interop to orchestrate the Lotus Notes Client or...
  • Using ODBC to expose the underlying tables of a Domino application.
This How To focuses on the second option, specifically abstracting the Platform from the ODBC connection details by creating a Linked Server in MS SQL Server (an alternative here would be to perform the ODBC work inside an extension).
I've researched a number of instructions available on the web and I've tested the steps to created a linked server but none of tutorials we I found seemed explain well enough what you need to do. Below you can find the steps I've learned through these experiments.

I've actually tested them from start to finish in clean environment to make sure they worked just fine.
 
Note that these steps are specifically for setting up the connection for a 64bit SQL Server. If you're using 32bit the steps will be different. All the steps below are to be performed on the machine where the Database server is running.
 
1. Download and install Lotus Domino Server
  • Go to http://www.ibm.com/developerworks/downloads/ls/lsndad/ and choose Download Trial
  • You'll have to login with an IBM login. Create one if you don't have it.
  • In the next screen choose "IBM Domino Enterprise Server V9.0.1 Social Edition Multiplatform English Trial eAssembly" and click continue
  • After confirming the legal stuff, you'll get to a screen where you should download the file "DOMI_SRV_9.01WIN_64_EN_FULL_-TRIAL.exe  (935 MB)"
  • Install it. You can use the defaults for everything. Choose to configure it as a "Domino Utility Server" when asked.
2. Configure Lotus Domino Server
  • Even though you will not actually use the server. You need to configure it as it it was a real server.
  • Double click "IBM Domino Server" on your desktop and follow the wizard (just click next until the last step and you'll be fine). You'll just need set some passwords and you can use the defaults for everything else.
    Inline image 6
  • Disable the Lotus Domino Services to make sure they don't start when you restart the machine (you really need to this, otherwise the odbc connection will not work)
    Inline image 7
     
     
     

    Inline image 8
    Inline image 9
     
     
     
3. Download and install NotesSQL ODBC drivers
4. Configure authentication for NotesSQL
  • Open the "NotesSQL Authentication List Manager" by opening Windows Explorer in the NotesSQL installation folder and double clicking Nsql_ALM.exe 
    Inline image 3
     
     
     
  • Fill in the "Path to NOTES.INI..." as in the screenshot below, click "Display list" and then, "Add user..."
    Inline image 4
     
     
  • Set the "Location of Notes ID" as set below and click OK 
    Inline image 5
     
     
     
  • Click "Save List" and then "Close"
5. Change your system Path variable
  • Go to the "Control Panel"
  • Open "System"
  • Click "Advanced system settings" on the left
  • Click "Environment Variables"
  • In "System variables" double click "Path"
  • Add ";C:\Progra~1\IBM\Domino\data;C:\Progra~1\IBM\Domino;C:\NotesSQL" to the end of the Value and click OK
6. Configure the ODBC data source pointing to a local file or to a server
  • Open to ODBC Data Source Administrator
    Inline image 1
     
     
     
  • Go to the "System DSN" tab and click "Add..."
     Inline image 2
     
     
     
  • Select "Lotus Notes SQL Driver (*.nsf)" and click Finish
  • Fill in details as seen in the screen below (in this scenario I'm connecting to a local file on the same location as the DB server)
    Inline image 10
     
     
     
  • Click OK and close the ODBC Data Source Administrator
7. Configure the Linked Server in MS SQL Server
  • Open SQL Server Management Studio and connect to your Database
  • Expand "Server Objects" and right click "Linked Servers"
    Inline image 11
     
     
     
  • Select "New Linked Server" and fill in the form as seen in the screenshot below
    Inline image 12
     
     
  • Click OK and your Linked Server is ready!
8. Test it
  • Create a new query window and test it by using, as an example SELECT * from openquery(NOTES, 'select * from Person') and you should get some nice results
    Inline image 13
9. Create Views to allow introspection with Integration Studio
  • You may create views by using, for example CREATE VIEW LN_Person AS SELECT * from openquery(NOTES, 'select * from Person')
     
    Inline image 15
  • This will allow you to then create introspect and create a connection using Integration Studio
One more thing... For the OutSystems applications to be able to access the data of the linked server in runtime you need to change the permissions of the OSRuntime database user. This user is the one used to access data by the running applications.
I haven't been able to figure out the exact permissions needed but, for a proof of concept phase, you can just give this user sysadmin permission and it will work fine.
 
Inline image 1

Hope this helps someone out there in the community!

PS: Note to the SYS ADMINS in this forum - what would be the best set of permissions to set for the OSRuntime user in this context?
PS2: You can find in attachment the sample Lotus application I'm using in this tutorial
Pedro,
This is a very useful tip.
As an alternative to linked servers and for option 1 I also have an example (Platform 9 only). 
This sample allows you to understand "How to connect programmatically to a Lotus Note DB file with the Outsystems Platform".

Instructions:

- Install Lotus Notes Client (ex: NOTES_9.0.1_WIN_EN_EVALUATION) on OutSystems Platform Server and test it by opening a NSF file (installation folder ....\IBM\Notes\Data includes several NSF files you can use).
- Publish the application (LotusNotesInteropSample) attached into the OutSystems Platform (V9) server
- Go to MS IIS OutSystems Platform Server and create a 32 bit Application pool and move the LotusNotesInteropSample application to this application pool. When you create the 32 bit application pool you must set its pipeline mode to "Classic".
 
- Test the application by inserting the input parameters (NSF file path - make sure access permissions are ok, View name and View Columns to read). You can test it using DB file  names.nsf  (it comes with lotus client), using View My Contacts (insert some contacts first using Lotus Client) and columns like FullName, Address, PhoneNumber...
 
I hope this code attached is also a good help for you.
 
Cheers,
FM