2

I'm trying to login from my linux server to a mssql server, unfortunatly the passsword contains the character . It seems this character does not get send through (properly). Anyone know how to make this work?

As you can see in the log, the freedts configuration is working and is resolving the hostname to the correct ip and port. But giving a closer look to the package in which my passwword is sent, it seems is getting replaced by ...

00d0 00 09 4d 79 e2 82 ac 50-61 73 73 77 6f 72 64 00 |..My...P assword.|

freetds.conf

[mannequin]
        host = XX.XXX.XXX.XXX
        port = 55214
        tds version = auto
        dump file = /var/www/vhosts/example.com/httpdocs/temp/freetds.log

php

<?php
        $servername = 'mannequin';
        $user = 'webshop';
        $pass = 'My€Password';
        //$pass = 'azerty';
        $dsn = 'dblib:charset=UTF-8;host='.$servername;

        try {
            $con = new PDO($dsn, $user, $pass);
        }catch(\Exception $e) {
            echo $e->getMessage().'<hr />';
            highlight_file(__DIR__ . '/../../temp/freedts.log');
        }
        exit;

freetds.log

log.c:196:Starting log file for FreeTDS 0.91
    on 2018-01-25 17:38:30 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x7f0f2b5f1670, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:349:setting up conversions for client charset "UTF-8"
iconv.c:351:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:391:preparing iconv for "ISO-8859-1" <-> "ISO-8859-1" conversion
iconv.c:394:tds_iconv_open: done
net.c:205:Connecting to XX.XXX.XXX.XXX port 55214 (TDS version 4.2)
net.c:270:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:310:tds_open_socket() succeeded
util.c:156:Changed query state from DEAD to IDLE
net.c:741:Sending packet
0000 02 00 02 00 00 00 00 00-70 75 62 6c 69 34 75 2d |........ xxxxxxx-|
0010 77 65 62 30 30 32 2e 73-72 76 2e 63 6f 6d 62 65 |xxxxxx.s rv.xxxxx|
0020 6c 6c 2d 6f 70 73 1e 77-65 62 73 68 6f 70 00 00 |ll-ops.w ebshop..|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 07 4d 79-e2 82 ac 50 61 73 73 77 |......My ...Passw|
0050 6f 72 64 00 00 00 00 00-00 00 00 00 00 00 00 00 |ord..... ........|
0060 00 00 00 00 0d 31 33 39-33 36 00 00 00 00 00 00 |.....139 36......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 05 03 01 06 0a-09 01 00 00 00 00 02 00 |........ ........|
0090 00 00 00 00 50 48 50 20-66 72 65 65 74 64 73 00 |....PHP  freetds.|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 0b 6d 61 6e 6e 65-71 75 69 6e 00 00 00 00 |...manne quin....|
00c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00d0 00 09 4d 79 e2 82 ac 50-61 73 73 77 6f 72 64 00 |..My...P assword.|
00e0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01b0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 0d 04 02 00 00 44 42-2d 4c 69 62 72 61 72 79 |......DB -Library|
01e0 0a 00 00 00 00 00 0d 11-75 73 5f 65 6e 67 6c 69 |........ us_engli|
01f0 73 68 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |sh...... ........|

net.c:741:Sending packet
0000 02 01 00 4c 00 00 00 00-00 00 00 00 00 00 0a 00 |...L.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 75 74 66 |........ .....utf|
0020 38 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |8....... ........|
0030 00 00 00 00 00 00 00 00-00 00 00 04 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-00 00 00 00             |........ ....|

token.c:328:tds_process_login_tokens()
net.c:555:Received header
0000 04 01 00 50 00 37 01 00-                        |...P.7..|

net.c:609:Received packet
0000 04 01 00 50 00 37 01 00-aa 3c 00 18 48 00 00 01 |...P.7.. .<..H...|
0010 0e 20 00 4c 6f 67 69 6e-20 66 61 69 6c 65 64 20 |. .Login  failed |
0020 66 6f 72 20 75 73 65 72-20 27 77 65 62 73 68 6f |for user  'websho|
0030 70 27 2e 10 53 45 52 56-45 52 50 43 5c 53 51 4c |p'..SERV ERPC\SQL|
0040 32 30 31 34 00 01 00 fd-02 00 00 00 00 00 00 00 |2014.... ........|

token.c:337:looking for login token, got  aa(ERROR)
token.c:122:tds_process_default_tokens() marker is aa(ERROR)
token.c:2588:tds_process_msg() reading message 18456 from server
token.c:2661:tds_process_msg() calling client msg handler
dbutil.c:85:_dblib_handle_info_message(0x7f0f27e41c70, 0x7f0f2b5f1670, 0x7fff42a4de00)
dbutil.c:86:msgno 18456: "Login failed for user 'webshop'."
dblib.c:5780:dbgetuserdata(0x7f0f2b5927f0)
dblib.c:5780:dbgetuserdata(0x7f0f2b5927f0)
token.c:2674:tds_process_msg() returning TDS_SUCCEED
token.c:337:looking for login token, got  fd(DONE)
token.c:122:tds_process_default_tokens() marker is fd(DONE)
token.c:2339:tds_process_end: more_results = 0
        was_cancelled = 0
        error = 1
        done_count_valid = 0
token.c:2355:tds_process_end() state set to TDS_IDLE
token.c:2370:                rows_affected = 0
token.c:438:tds_process_login_tokens() returning TDS_FAIL
login.c:466:login packet accepted
util.c:156:Changed query state from IDLE to DEAD
util.c:331:tdserror(0x7f0f27e41c70, 0x7f0f2b5f1670, 20002, 0)
dblib.c:7929:dbperror(0x7f0f2b5927f0, 20002, 0)
dblib.c:7981:20002: "Adaptive Server connection failed"
dblib.c:5780:dbgetuserdata(0x7f0f2b5927f0)
dblib.c:8002:"Adaptive Server connection failed", client returns 2 (INT_CANCEL)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1443:dbclose(0x7f0f2b5927f0)
dblib.c:258:dblib_del_connection(0x7f0f0d351640, 0x7f0f2b5f1670)
mem.c:615:tds_free_all_results()
dblib.c:305:dblib_release_tds_ctx(1)
dblib.c:5882:dbfreebuf(0x7f0f2b5927f0)

DTS version is 4.2 and not 7 or 8. When using 7 or 8 the log shows me:

The server sent an unexpected EOF

and then the connection closes.


Small update

The problem got "solved" by requesting a new password without specials characters. But it has to be noted I had to change the DTS version to 8.0 because otherwise I could not receive unicode data (general error 4004)

It has to be noted I still could connect to the server with DTS 8.0 as well, so the EOF response I got in that version had nothing to do with a version mismatch but also due to the in the password!

Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

DarkBee
  • 16,592
  • 6
  • 46
  • 58
  • that ^ and check the server's default encoding also. Edit: now that comment was deleted above. – Funk Forty Niner Jan 25 '18 at 16:52
  • The `PHP` file is encoded in `UTF-8` and i'm not using `mysql` but `mssql` for this – DarkBee Jan 25 '18 at 16:52
  • Right, I just saw the flag for sql-server... my bad. Sorry Funk ;) – IncredibleHat Jan 25 '18 at 16:52
  • @FunkFortyNiner my `linux` server or the server which is hosting the `mssql server`? – DarkBee Jan 25 '18 at 16:53
  • @DarkBee both, and are those files encoded with or without BOM? could be it. – Funk Forty Niner Jan 25 '18 at 16:53
  • 1
    I would change the password ^^ – Johan Jan 25 '18 at 16:53
  • @FunkFortyNiner the linux one is `UTF-8 w/out BOM`. Dunno on the target the server. It's just a machine running windows 10 – DarkBee Jan 25 '18 at 16:55
  • `iconv.c:349:setting up conversions for client charset "UTF-8"` ... ? Why would it be converting down? – IncredibleHat Jan 25 '18 at 16:55
  • @Johan that is the last resort yes, but there for i need to contact some other person to change it for me. Don't have much privileges on the target server – DarkBee Jan 25 '18 at 16:56
  • @IncredibleHat Coudln't tell, only thing I see is that the detected `DTS` version is `4.2` and not `7` or `8`, that is perhaps the problem? – DarkBee Jan 25 '18 at 16:57
  • You have it set to `tds version = auto`... try forcing it? I really don't think that would help though. – IncredibleHat Jan 25 '18 at 16:59
  • When using `7` or `8` the log shows me `The server sent an unexpected EOF` and then the connection closes – DarkBee Jan 25 '18 at 17:01
  • In Googling your above error, have a look at https://social.technet.microsoft.com/Forums/en-US/9e441486-863b-49fb-a3b5-e1c872f252f9/received-an-unexpected-eof-or-0-bytes-from-the-transport-stream?forum=biztalkgeneral - is this SSL related by any chance? There were more hits for that error though. Another being https://www.limilabs.com/blog/received-unexpected-eof-0-bytes-from-transport-stream – Funk Forty Niner Jan 25 '18 at 17:03
  • Nope there is no `SSL`, not on the domain i'm connecting from and not the target machine – DarkBee Jan 25 '18 at 17:05
  • Ok, leave it on auto, I saw this posting too... mmmmaybe has some helpful bits: https://stackoverflow.com/questions/37287329/freetds-how-to-set-charset-of-parameters-running-stored-procedure ... – IncredibleHat Jan 25 '18 at 17:05
  • @IncredibleHat good reference; seems it could be some form of encoding issue somewhere. – Funk Forty Niner Jan 25 '18 at 17:06
  • You could also do a test by sending in a value with ™ in it, as iconv will turn that into (TM), so if thats what you end up seeing, then there is definitely a down-conversion happening on the encoding ... now where, and how to stop it may be a big issue if you don't have control of the db server :( – IncredibleHat Jan 25 '18 at 17:12
  • 1
    The `OP` on the linked topic mentiod he only started seeing the conversion after he added the charset in his dsn, but the conversion is already happening in my logfile. Anyway `™` gets converted to `...` as well. – DarkBee Jan 25 '18 at 17:18
  • Well guessing i'll need to e-mail my contactperson tomorrow. Thanks for the effort though – DarkBee Jan 25 '18 at 17:19
  • Yeah, I'm out of ideas... good luck. – IncredibleHat Jan 25 '18 at 17:19
  • FWIW, nothing "gets converted to `...`". It's merely the hex editor not knowing how to interpret the bytes `e2 82 ac` exactly (which is UTF-8 for €). – deceze Mar 08 '18 at 13:29

0 Answers0