3

Successfully connect to the database through the SQL Server Management Studio. But use the pymssql connection failed :

pymssql error:

pymssql.OperationalError: (17892, "Logon failed for login 'xxx' due to trigger exe cution.DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check mess ages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server co nnection failed (xxxx\xxxx)\n")

version info:

SQL Server version is 2014 12.0.6024.0.

The Linux server operating system is SUSE Linux Enterprise Server 12 (x86_64).

pymssql version: pymssql-2.1.4

./tsql -C :

Compile-time settings (established with the "configure" script)
                            Version: freetds v1.00.9
             freetds.conf directory: /usr/local/freetds/etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.1
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: no
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: no

more freetds.log

util.c:375:tdserror: returning TDS_INT_CANCEL(2)
net.c:216:Connecting to x.x.x.x port 1433 (TDS version 4.2)
net.c:242:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:343:tds_open_socket() succeeded
packet.c:741:Sending packet
......
token.c:306:looking for login token, got  aa(ERROR)
token.c:125:tds_process_default_tokens() marker is aa(ERROR)
token.c:2328:tds_process_info() reading message 17892 from server
token.c:2403:Msg 17892, Severity 14, State 1, Server xxxxx\xxxxx, Line 1
Logon failed for login 'xxxx' due to trigger execution.
token.c:2417:tds_process_info() returning TDS_SUCCESS
token.c:306:looking for login token, got  fd(DONE)
token.c:125:tds_process_default_tokens() marker is fd(DONE)
token.c:2065:tds_process_end: more_results = 0
                was_cancelled = 0
                error = 1
                done_count_valid = 0
token.c:2082:                rows_affected = 0
token.c:2085:tds_process_end() state set to TDS_IDLE
token.c:415:tds_process_login_tokens() returning TDS_FAIL
login.c:530:login packet accepted
query.c:3796:tds_disconnect()
util.c:165:Changed query state from IDLE to DEAD
util.c:322:tdserror(0x7f676bb19200, 0x228d1c0, 20002, 0)
util.c:358:tdserror: client library not called because either tds_ctx (0x7f676bb19200) or tds_ctx->err_handler is NULL
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
util.c:322:tdserror(0x1cca6f0, 0x228d1c0, 20002, 110)
dblib.c:7949:dbperror(0x22d8430, 20002, 110)
dblib.c:8017:dbperror: Calling dblib_err_handler with msgno = 20002; msg->msgtext = "Adaptive Server connection failed (xxxxx\xxxxx)"
dblib.c:8039:dbperror: dblib_err_handler for msgno = 20002; msg->msgtext = "Adaptive Server connection failed (xxxxx\xxxxx)" -- returns 2 (INT_CANCEL)
util.c:352:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1260:tdsdbopen: tds_connect_and_login failed for "xxxxx\xxxxx"!
dblib.c:1476:dbclose(0x22d8430)
dblib.c:241:dblib_del_connection(0x7f676bd29860, 0x228d1c0)
mem.c:644:tds_free_all_results()
dblib.c:288:dblib_release_tds_ctx(1)
dblib.c:5881:dbfreebuf(0x22d8430)
dblib.c:749:dbloginfree(0x21bce80)
Traceback (most recent call last):
  File "src/pymssql.pyx", line 642, in pymssql.connect
pymssql.OperationalError: (20002, 'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (xxxxx\xxxxx)\nNet-Lib error during Connection timed out (110)\n')

tsql -H

LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER= C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C" locale charset is "UTF-8" using default charset "UTF-8" Msg 18456 (severity 14, state 1) from xxxx\xxxxx Line 1: "Login failed for user 'xxxx'.

What should I do to fix this issue?

Jaina
  • 31
  • 1
  • 5
  • Can you connect using `tsql -H x.x.x.x -p 1433 -U your_username -P your_password` (with x.x.x.x replaced by the actual IP address)? If not, does the freetds.log still show the "Logon failed for login 'xxxx' due to trigger execution." message? – Gord Thompson Jul 05 '19 at 13:42
  • The error message is : locale is "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER= C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C" locale charset is "UTF-8" using default charset "UTF-8" Msg 18456 (severity 14, state 1) from xxxx\xxxxx Line 1: "Login failed for user 'xxxx'." Error 20002 (severity 9): Adaptive Server connection failed There was a problem connecting to the server – Jaina Jul 06 '19 at 05:44
  • "Logon failed for login 'xxxx' due to trigger execution" suggests that the problem is specific to that SQL Server login. Can you connect from SSMS using those same credentials? If so, the login trigger may impose some restrictions on the machines from which that SQL Server login can connect (assuming that the SSMS machine and the pymssql/FreeTDS machine are different boxes). – Gord Thompson Jul 08 '19 at 13:17

0 Answers0