I have a C# application that connects to a SQL server with SQL authentication, but the machines that are to be using it aren't on the domain.

I've been trying to solve this for several days now. On my development machine the connection string works perfectly fine and isn't using Windows authentication. As soon as it is on one of the others outside the domain, including non-domain accounts on my machine, this error occurs.

login failed. the login is from an untrusted domain and cannot be used with windows authentication. Error: 18452

The connection string is (details omitted and edited for readability):

Data Source=[servername];

Initial Catalog=[Database];

Persist Security Info=True;

User ID=[username];



I've also tried additional string options such as Trusted_Connection (tried true and false) and Integrated Security=SSPI.

All the server connection settings are correct (allow remote connection, ports, both Windows and SQL authentication allowed), and I can connect to the server on SSMS using the username and password just fine.

Assuming my settings are correct (there's bound to be something wrong somewhere), doesn't this defeat the point of using a SQL user login if I can't log in remotely? Anyway, any help is appreciated.

  • What is the connection string you are actually using? It sounds like something in there is forcing Windows authentication anyway. May 4, 2017 at 11:15
  • @ShannonBlank Edited post for details.
    – N Nooblet
    May 4, 2017 at 11:30

2 Answers 2


Fair warning: I am not a C# developer (nor do I play one on TV).

The error message insists it's trying to use windows authentication, even if you're not. ("Integrated Security=SSPI" means you're using Windows authentication, for example, as does "Trusted Connection.") So I'm wondering if one of the details you've left out is for windows authentication only.

This MSDN link is for SQL Authentication only and may or may not help you. This MSDN link is for Windows Authentication only and may tell you options you need to avoid.

  • In an earlier attempt when researching this, I found something about an "SSPI Handshake" error. In other connection strings in the same application's config (that use Windows Authentication), Integrated Security is set to True. I thought setting to SSPI might be a fix. The string details are exactly what I posted. I even removed everything except Source, Catalog, Username and Password (just like the first link you posted) Thanks for the links and help.
    – N Nooblet
    May 5, 2017 at 6:36

It turns out that even if you use the Visual Studio Wizard to use a certain connection string, VS doesn't change other references to it. Code and settings files were still using the old connection string.

I was not familiar with the project in its entirety as I was just tasked with modifying it for a tiny bit more functionality.

So, for others having the same issue in the future and can't seem to find an answer:

  • If all server settings are correct, then it must be your code.
  • Make sure that if you are referencing a connection string in your project via Properties.Settings.Default.ConnectionStringName or something that isn't a hardcoded connection string, that it is referencing the correct one and that there aren't any other strings when you're done.

If the mods want to move this to StackOverflow since this was actually a code issue, up to you guys.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .