tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.24k stars 470 forks source link

Trusted connection string? #244

Closed KevinBurton closed 8 years ago

KevinBurton commented 8 years ago

I have the configuration like:

var sql = require('mssql');

var config = { server: 'db3dev', database: 'EForms', connectionString: 'Driver=msnodesqlv8;Server=db3dev;Database=EForms;Trusted_Connection=true;', options: { trustedConnection: true, useUTC: true } }

But I always get an ELOGIN error. What am I doing wrong?

Thank you.

patriksimek commented 8 years ago

This is the way to configure mssql to use msnodesqlv8 driver.

var sql = require('mssql');

var config = {
    driver: 'msnodesqlv8',
    server: 'db3dev',
    database: 'EForms',
    options: {
        trustedConnection: true,
        useUTC: true
    }
}
KevinBurton commented 8 years ago

Thank you.

On Dec 21, 2015, at 6:31 PM, Patrik Simek notifications@github.com wrote:

This is the way to configure mssql to use msnodesqlv8 driver.

var sql = require('mssql');

var config = { driver: 'msnodesqlv8', server: 'db3dev', database: 'EForms', options: { trustedConnection: true, useUTC: true } } — Reply to this email directly or view it on GitHub.

d3x0r commented 7 years ago

I had issues connecting with latest mssql and this driver... I don't see anything wrong... but I keep getting a user error.

cred: { driver: 'msnodesqlv8',
  server: 'localhost',
  database: 'hall',
  options: { trustedConnection: true } }

error: { Error: Login failed for user ''.

aaroncalderon commented 7 years ago

@d3x0r Downgrade to mssql@3.x and try again.

d3x0r commented 7 years ago

I would; but the program is already updated to the 4.0 API... so other than to test and say 'ya, that works' I'm not going to update the thing that already works. I have a user/password I can use... just would rather have it not in config.json

aaroncalderon commented 7 years ago

@d3x0r Good point.

I have a user/password I can use... just would rather have it not in config.json

I do not know the exact circumstances arround your setup and how will you deploy it.

I wonder... Is that your only concern? Are you pushing the file confing.json to your repo?

If you want to avoid that information to end up in your repo then you can:

If you just do not want the information on the config.json the we are on the same boat.

As I understand, mssql@4.x and msnodesqlv8 are not playing along right now, sorry (can't remember the issue where I read about it).

d3x0r commented 7 years ago

Ya; the config isn't such a big deal, internally for development our user/password is not hte same as the field, and the repository is private.... but when it gets to the field, anyone can just browse and see the user/password in the configuration. (yes they would have to know that it's a thing and where it would be; but still) I still think it's kinda lame that I have to specify username/password to authenticate a connection; when I was using MySQL, I was using myODBc, which stores the password in the registry, but we can prevent users from editing/viewing the registry, and the data sources dialog doesn't show the password either. (just a peeve about MSSQL) It's alright; next project I do I'll see about sticking with the older version of mssql npm.
I also ran into an issue connecting to another server that was like 'invalid value 0' which turned out to be about the version negotiation not working with that version of mssql :) but that I found another issue about and was able to fix it with an option. anyway; maybe someday this can be fixed :) it kinda seems that options isn't being passed to the driver through 4.x; so maybe this should actually be a Issue for them.