[freetds] dbi:ODBC:DSN=... odbc.ini UID and PWD ignored ?

TJ freetds at iam.tj
Fri Apr 19 09:46:38 EDT 2013


On Ubuntu 12.04 and 13.04 I'm seeing a failure to authenticate to an MS SQL Server when UID and PWD are included from the DSN stanza in odbc.ini. When they are added to the connection string the
connection is successful.

Table 4.1 of "Connection attributes" says "The following table defines all possible ODBC connection attributes for the FreeTDS ODBC driver. Which ones you'll need depends on how you set yourself up.
They may appear in your connection string, or in odbc.ini." but my experience doesn't seem to match that.

#  apt-cache policy freetds-common tdsodbc unixodbc  | grep -B1 Installed
freetds-common:
  Installed: 0.91-3
tdsodbc:
  Installed: 0.91-3
unixodbc:
  Installed: 2.2.14p2-5ubuntu4


I'm using a Perl script for testing which tries these variations of the connection string. The first works, the second fails:

#!/usr/bin/perl

use DBI;

my $DSN = 'Northwind';
my $user = 'INT\TJ';
my $password = 'password';

my $dbh = DBI->connect("dbi:ODBC:DSN=$DSN;UID=$user;PWD=$password", {PrintError => 0});
my $dbh = DBI->connect("dbi:ODBC:DSN=$DSN", {PrintError => 0});
#...

The error is:

$ ./db_test_northwind.pl
DBI connect('DSN=Northwind','HASH(0x1ca7998)',...) failed: [unixODBC][FreeTDS][SQL Server]Login failed for user 'HASH(0x1ca7998)'. (SQL-42000) [state was 42000 now 08001]
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001) at ./db_test_northwind.pl line 10
ERROR: Failed to connect to DSN (Northwind).
ERROR MESSAGE: [unixODBC][FreeTDS][SQL Server]Login failed for user 'HASH(0x1ca7998)'. (SQL-42000) [state was 42000 now 08001]
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001) at ./db_test_northwind.pl line 14.

The system configuration is:

# cat /etc/freetds/freetds.conf
[TJSBS2003]
    host = 10.254.1.253
    port = 1433

# cat /etc/odbcinst.ini
[FreeTDS]
Description  = MS SQL Server via Free TDS
Driver       = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup        = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount   = 2

# cat /etc/odbc.ini
[Northwind]
Description	= Test on MS SQL Server 2000 SP3 on SBS2003
Driver		= FreeTDS
TDS_Version	= 8.0
Servername	= TJSBS2003
Database	= Northwind
UID	    	= INT\TJ
PWD		= password


More information about the FreeTDS mailing list