I am able to connect to a SQL Server database using a SQL account. How do I connect to the same SQL Server using windows auth? I have already added trustedConnection
as true
.
Note - I am passing the password for the domain\testetl
account because I am running this from AWS Lambda where I cannot login using that user.
'use strict';
const sql = require('mssql');
exports.handler = (event, context, callback) => {
const config = {
server: 'ip',
port: 45,
user: 'domain\testetl',
password: 'g',
database: 'central',
options: {
trustedConnection: true
}
};
sql.connect(config, (err) => {
if (err) {
console.log(err);
callback(err);
} else {
const req = new sql.Request();
req.query('SELECT top 10 * FROM STATS', (error, result) => {
if (error) {
console.log(error);
callback(error);
} else {
console.log(result);
sql.close();
callback(null, result.recordset);
}
});
}
});
sql.on('error', (err) => {
console.log(err);
callback(err);
});
};