OHDSI Home | Forums | Wiki | Github

Setup for OHDSI R packages to work with Windows authentication from a non-Windows machine


(Karthik) #1

For a long time we’ve struggled to get the OHDSI packages to run on a non-Windows machine. I finally got it to work, so I thought I’d share my test setup.

Environment
client - MacOS running BigSur and where OHDSI R packages will run
database - MS SqlServer 2019 (15.0.2)
AD - Active Directory 2008 R2

Setup
Background: Kerberos is used by Active Directory, you need to have the appropriate packages installed on your client machine. For MacOS, the Kerberos packages are usually already installed. On Linux, you’ll have to install krb5-user. Most of this setup comes from [5].

  1. On the non-windows client machine, create or update /etc/krb5.conf so that it points to your AD server. Here’s an example of krb5.conf:
    [libdefaults]
    default_realm = DOMAIN.COMPANY.COM
     
    [realms]
    DOMAIN.COMPANY.COM = {
      kdc = dc-33.domain.company.com
    }
    
  1. Run kinit <username>@DOMAIN.COMPANY.COM to get a ticket granting ticket from the kerberos domain controller (KDC). (NOTE: you want to make sure your KDC is accessible from your machine. This was an issue for me when I VPN’ed.)

  2. Download the latest MSSql JDBC driver. I used v8.2.2.

  3. Try to connect to the database with the following code in RStudio:

    library(devtools)
    library(DatabaseConnector)
    connectionDetails <- createConnectionDetails(dbms="sql server", pathToDriver =  , server=, extraSettings="authenticationScheme=JavaKerberos")
    c <- connect(connectionDetails = connectionDetails)
    

    In RStudio, you should see that the variable c has a value and the new connection in the connections tab as well.

Hopefully, this will help other sites that are using non-Windows environments to run OHDSI packages and their institutions do not allow sql server local accounts.

References
[1] Connect Azure Data Studio to SQL Server using Windows authentication - Kerberos
[2] Using Kerberos integrated authentication to connect to SQL Server
[3] Overview of Service Principal Name and Kerberos authentication in SQL Server
[4] Active Directory Authentication: How does Kerberos and NTLM work
[5] How to enable Integrated Authentication on macOS and Linux using Kerberos


Failure to connect to server - Is it SQL vs Windows Authentication?
t