【问题标题】:Perl dbi:Sybase Connect to SQL Server that uses Windows Authentication from linux machinePerl dbi:Sybase 从 linux 机器连接到使用 Windows 身份验证的 SQL Server
【发布时间】:2019-02-06 04:24:25
【问题描述】:

我正在使用 perl DBI 通过 dbi:Sybase 从 linux 机器连接到 SQL Server,但是当我尝试连接时,它给了我类似

的错误

DBI connect('DBName','DOMAIN\UserName',...) failed: Server message number=18452 severity=14 state=1 line=1 server=SERVERNAME text=Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34) Server DATAMART, database Message String: Adaptive Server connection failed at connect.pl line 37

我的代码是:

BEGIN{
   $ENV{SYBASE} = "/opt/sybclient-12.5.1";
   $ENV{FREETDSCONF} = "PATH/config/freetds.conf";
}

use lib "PATH/perl-lib/lib64/perl5";
use lib "PATH/perl-lib/share/perl5/";


my $lib = "PATH/FreeTDS_32bit/libct.so.4.0.0";
DynaLoader::dl_load_file($lib, 1) or die "Unable to load freetds libct.so: $!\n";

$host = 'ServerName';  $port = 'PORT';
$database = 'DBName';  $user = 'DOMAIN\\userName'; 
$auth = 'PASS';

$_dmDBH = DBI->connect(dbi:Sybase:server=$host; database=$database;port=$port","$user", "$auth") || die "Database connection not made: $DBI::errstr";

【问题讨论】:

  • 好吧,这看起来很有趣:stackoverflow.com/questions/546746/…
  • 您能否确认您是在尝试连接到在 Windows 上运行的 MS SQL Server 还是 Sybase 实例,因为任何一个 RDBMS 都可以使用“SQL Server”。
  • @Rich Campbell 我正在尝试连接到 MS SQL Server。

标签: sql-server perl dbi


【解决方案1】:

我可以用 freeTds 解决这个问题,在 freeTds 配置文件中我们需要将 ntlmv2 设置为 yes

[PACKAGE-NAME]
        host = <HOSTANME>
        database = <DB-Name>
        tds version = 8.0
        use ntlmv2 = yes
        client charset = UTF-8

【讨论】:

    猜你喜欢
    • 2016-10-16
    • 2013-09-07
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    • 2019-12-02
    • 1970-01-01
    相关资源
    最近更新 更多