node-sqlserver-v8 icon indicating copy to clipboard operation
node-sqlserver-v8 copied to clipboard

[Question] What is the authentication detail if set trustedConnection to be true?

Open Gong-Allen opened this issue 1 year ago • 2 comments

After reading some documentation I know I can use below configuration to enable Windows Authentication

var config = {
    driver: "msnodesqlv8",
    server: "localhost",
    database: "MyDatabase",
    options: {
        trustedConnection: true
    },
};

So what is the authentication protocol for this Windows Authentication? Thanks.

Gong-Allen avatar Apr 18 '24 02:04 Gong-Allen

i would not use this, simply use a connection string

const mssql= require('mssql/msnodesqlv8')
const {runQuery} = require("./query");
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

async function runner() {
    const res = await runQuery(mssql, connectionString, 'select top 3 * from syscolumns')
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done')
})

query.js

async function runQuery(mssql, connectionString, sqlString) {
    const config = {
        connectionString: connectionString
    }

    const pool = await mssql.connect(config)
    const res = await pool.query(sqlString)
    await pool.close()
    return res
}

exports.runQuery = runQuery

TimelordUK avatar Apr 23 '24 21:04 TimelordUK

Hi @TimelordUK , Thanks for your response, but I am not asking how to use Windows Authentication, I am asking the protocol of this Windows Authentication, is it Kerberos?

Gong-Allen avatar Apr 24 '24 05:04 Gong-Allen