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

Frediano Ziglio freddy77 at gmail.com
Fri Apr 19 11:41:23 EDT 2013


2013/4/19 TJ <freetds at iam.tj>

> 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.
>

At http://www.freetds.org/userguide/odbcconnattr.htm 4.1 table state
exactly that UID/PWD are not used from odbc.ini (only connection string).
This for security reasons. If your documentation state the opposite
probably was wrong (we fixed documentation some time ago).

Use 7.1 as protocol version (you can also use 7.2), 8.0 is the former
version.

Also pass our driver even as setup, our driver has support for unixODBC and
procide functions to deal with setup stuff.

Regards,
  Frediano


> 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