The Microsoft SQL Server fails to connect with "CLI error trying to establish connection... Login failed..." when using Windows NTLM Authentication


The following error might occur when you run a LIBNAME to the Microsoft SQL Server and supply your Windows user ID as “domain\userd”:

CLI error trying to establish connection: [SAS][ODBC SQL Server Wire Protocol driver] Socket closed : [SAS][ODBC SQL Server Wire Protocol driver] 01006 : [SAS][ODBC SQL Server Wire Protocol driver] Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication.

This issue occurs in SAS® Viya® 2025.06 through 2025.11. This issue also occurs in SAS® 9.4M9 (TS1M9).

Workaround

To circumvent this issue, supply the domain name in the ODBC DSN option:

Domain=domainName

Then, remove the domain name from the USER= option in your LIBNAME statement.

Here is an example:

libname a sqlsvr dsn=xxxxx user=userid password=yyyyy;