denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 497 forks source link

Strange work with Windows authentication #629

Open MirkoGamerman opened 3 years ago

MirkoGamerman commented 3 years ago

use examples\simple\simple.go 1.

var (
    debug                    = flag.Bool("debug", true, "enable debugging")
    password                 = flag.String("mypass", "mypass", "the database password")
    port                *int = flag.Int("1433", 1433, "the database port")
    server                   = flag.String("192.168.9.15", "192.168.9.15", "the database server")
    user                     = flag.String("DOM\\domainuser, "DOM\\domainuser", "the database user")
)
...
    conn, err := sql.Open("sqlserver", connString)
    if err != nil {
        log.Fatal("Open connection failed:", err.Error())
    }
    defer conn.Close()
 row := conn.QueryRow("select 1")
    var somenumber int64
    err = row.Scan(&somenumber)
    if err != nil {
        log.Fatal("Scan failed:", err.Error())
    }
    fmt.Printf("somenumber:%d\n", somenumber)

Output: 2021/01/06 10:29:16 Scan failed:sql: no rows in result set

OS: Windows Server 2016 MSSQL Server version: Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) Sep 24 2019 13:48:23 Copyright (C) 2019 Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)

MirkoGamerman commented 3 years ago
  1. if using local mssql login - all ok
  2. if query "backup database..." with windows domain authentication - backup was created, but command query not wait finish process.
MirkoGamerman commented 3 years ago

I tested row := conn.QueryRow("select 1+1, 'abc'") The Wireshark showed the return of the result to the client, but program result: Scan failed:sql: no rows in result set

0000 00 0c 29 40 ef 08 00 0c 29 ba 5d 45 08 00 45 00 ..)@....).]E..E. 0010 00 63 7e f9 40 00 7e 06 11 73 c0 a8 09 0f c0 a8 .c~.@.~..s...... 0020 e1 c8 05 99 d2 6a 0a 46 27 76 d8 38 dd 68 50 18 .....j.F'v.8.hP. 0030 03 fc c3 f7 00 00 04 01 00 3b 00 34 01 00 81 02 .........;.4.... 0040 00 00 00 00 00 21 00 26 04 00 00 00 00 00 20 00 .....!.&...... . 0050 a7 03 00 19 04 d0 00 00 00 d1 04 02 00 00 00 03 ................ 0060 00 61 62 63 fd 10 00 c1 00 01 00 00 00 00 00 00 .abc............ 0070 00 .