I am trying to connect to a MS SQL Server database from my NodeJS server application and while it works flawlessly on my local machine using localhost/127.0.0.1 when I push it to a real server I get an Auth error.
The error I am getting is as follows:
The login is from an untrusted domain and cannot be used with Windows authentication
So I am thinking that maybe its different domains but my domains are as follows:
000001.mysubdomain.mydomain.com
ct000002.mysubdomain.mydomain.com
So I'm not a networking guy but I would assume that in this case both the MS SQL Server and my NodeJS Server are actually on the same domain, am I correct in assuming that or incorrect?
Some more info - in both cases the IP addresses share the same first number but the rest are different - SS.XX.XX.XX - Where SS is the same numbers and XX are different - does this suggest that they are in fact on different domains?
In addition to this if it was a domain issue then why would it work on my local machine?
So if we can eliminate that it is not a domain issue then I'm not sure where to go, here is my code, I am using the Tedious-NTLM NodeJS module - https://www.npmjs.com/package/tedious-ntlm
var tds = require("tedious-ntlm"); //Get the tedious model for NTLM connection to the SQL Server
//Set up config for logging into the DB
var config = {
userName: 'myusername', //Username
domainName: "mydomain", //Domain
password: 'mypassword', //Password
server: '000001.mysubdomain.mydomain.com' //Database address
};
function getDataFromSQLServer(callback){
var connection = new tds.Connection(config); //Configure a connection
//When the database is connected to we get this event
connection.on('connect', function(err) {
// If no error, then good to go...
if(err){
console.log('err = ' + err); //Log the error to the console
}
else{
executeStatement(callback); //Execute the test statement
}
}
);
As you can see here when my function is called I log an error, I get an error here when trying to run the code from my server but I have no issue when running it from my local machine.
To get more information on the error I have the following code:
connection.on('errorMessage', function(err){
console.log('full error = ' + JSON.stringify(err)); //Log the error to the console
});
Which gives me the following info:
full error = {"number":18452,"state":1,"class":14,"message":"Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.","serverName":"000001","procName":"","lineNumber":1,"name":"ERROR","event":"errorMessage"}
Again if run on my local machine everything works correctly but if I run from my server I get the errors, I am wondering if this really is a domain issue or if the error message is incorrect and there is something else wrong?