Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gong-Allen opened this issue Apr 18, 2024 · 2 comments

Comments

@Gong-Allen
Copy link

Gong-Allen commented Apr 18, 2024

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.

@TimelordUK
Copy link
Owner

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

@Gong-Allen
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants