SQL SERVER – Fix – Login failed for user ‘username’. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)

Earlier this week, I was on vacation and did not check my emails for three days and when I returned, I found six different emails from 4 different people asking for the same problem.

When they attempted to login using their application to SQL Server they faced following error:

Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)

This is quite a common error and can happen when incorrect username is communicated to SQL Server. The fix is to provide correct username. This can also happen if you are attempting to login to SQL Server with SQL Username but it is only configured to connect to Windows Login. You can quickly fix this error by following steps listed below.

Solution/Workaround/Fix:

Open SQL Server Management Studio and right click on Server Node and select Properties

SQL SERVER - Fix - Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) errorconnect1

Now go to Security Tab and go to Server Authentical Area. Select SQL Server and Windows Authentication Mode.

SQL SERVER - Fix - Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) errorconnect2

You should be able to login with your SQL Server username. If you are not able to login with your SQL Server username after following above steps, it is quite possible your username is incorrect, please check again.

Reference: Pinal Dave (https://blog.sqlauthority.com)

SQL Error Messages
Previous Post
SQL SERVER – Check for Database Integrity – Notes from the Field #011
Next Post
Personal Technology – Inserting Image in PDF File with Adobe Acrobat X Pro

Related Posts

26 Comments. Leave new

  • Thank You.. I have question here?As I tried this option, I am unable to access the User details further. I have 10 users & I am getting user group not individual user id’s. Please help me.

    Reply
  • Perhaps it was not a coincidence that these emails all came together.

    I have had an application run smoothly on 20+ sites for years, only to have this reported from two sites last week.

    The connection string was in both cases specified in an UDL file that the application refers to, and I used trusted login. The user’s Windows account will (through an AD group) give access to both the file server and the database server. They should be able access neither, or both.

    I discovered that if the application was started from an UNC path, e.g. \serverfolderapp,exe, it would gives this error, but if the server folder \serverfolder was mapped to a drive letter, thereby starting from a path like m:app.exe, there was no problem.

    The connection strings used inside the app would be “FILE NAME=m:app.udl” or “FILE NAME=\serverfolderapp.udl” in the two cases. The first would work, the second wouldn’t, and would give the error you mention.

    I suspect that this can be a new security “feature” of Windows itself that has been introduced in a patch. What do you think?

    Reply
  • UZIEL MERCADO (@uzielmercado11)
    May 1, 2014 10:40 pm

    Amigo me está pasando ese error al crear un linked server de un servidor con sql server 2008 a uno con sql server 2000 service pack 2 en donde intento acceder por medio de sql server connection, me manda ese error, y si pruebo iniciando sesión al servidor no me da error que podrá ser?

    Ya valide y si tengo la misma configuraci´n.

    Reply
  • helo sir still i am not able to connect to the database. i created one login like ‘developper’ with password ‘developper’ but it still showing the same error message.

    i am a beginer in sql dba .
    please help me

    thank you

    Reply
  • but what we do when we r using windows auth mode . everyone know solution with mis mode but no one can help on win auth mode

    Reply
  • Nilesh Deshpande
    September 30, 2014 3:14 pm

    Hi Pinal,

    I have a classic situation here.

    I am using this connection string across all applications listed below.

    “provider=sqloledb;uid=sa;pwd=xxx;database=stocks;server=nilesh1”

    Server nilesh1 is configured to allow mixed mode authentication.

    Applications written in vb 6.0 are connecting smoothly with the above connection string.
    Sql Query Analyzer connects smoothly with those credentials.

    Only applications written in asp (running on a server other than nilesh1) cannot connect and give out this error.

    Any insights?

    Nilesh Deshpande

    Reply
  • thanks i resolved my problem

    Reply
  • Mthobisi Luthuli
    November 24, 2014 6:19 pm

    this works but you might want to RESTART your SQL instance when you are done with the changes mentioned above.

    Reply
  • Thanks man! You saved my life!

    Reply
  • thamnguyenit26
    March 31, 2015 9:49 am

    Hi sir,
    I have SQL server 2008. I had config all thing like this topic. when i connect .sql2008 and userDB + passDB, it’s OK, but when i connect by localhostsql2008 or 127.0.0.1sql2008. It’s not OK. I don’t know why ? can you help me, please. maybe i wrong in config connect by domain or IP. but i can not find them anywhere :(.

    Reply
  • thamnguyenit26
    March 31, 2015 9:51 am

    Hi sir,
    I have SQL server 2008. I had config all thing like this topic. when i connect .sql2008 and userDB + passDB, it’s OK, but when i connect by localhostsql2008 or 127.0.0.1sql2008. It’s not OK. I don’t know why ? can you help me, please. maybe i wrong in config connect by domain or IP. but i can not find them anywhere :(.
    I use plesk for hosting and this is example i have for a custommer :

    Error -2147217843

    Login failed for user ‘db_name’.

    Provider=sqloledb;Data Source=127.0.0.1SQL2008;User Id=user_db;Password=pass_db;

    Reply
  • thanks Dave!

    Reply
  • arnold marquez
    June 6, 2015 10:34 am

    possibly it has something to do with the version of the SQL native client you are using…:)

    Reply
  • Ramana Murthy
    July 29, 2015 9:48 am

    I am getting the ‘Microsoft SQL Server Native Client 11.0 : Login failed for user’ when i open the connection in Visual Basic application. I have verified SQL authentication mode, it is selected as both. I am using the connection string as “DRIVER={SQL Server Native Client 11.0};SERVER=127.0.0.1;Trusted_Connection=yes;Database=test;”. SQL 2012 installed in the server. Please help me out.

    Reply
  • Rakesh kaithvas
    January 27, 2017 6:27 pm

    Hello Sir,
    I am getting Error 18452 when connecting a Sql Server Management studio 2005 on a Local Server,this error I am getting on the Client machine.
    ” Login Failed for User”. The user is not associated with a trusted SQL Server connection.(Microsoft SQL Server Error:18452)
    Sql Server is Successfully login on my Server Machine,but this Error is only on my Client Machine.
    Please guide me I have Tried Every thing by starting the Services also.
    I am getting troubles in on My Clients Machines.

    Reply
  • |80040e4d|[Microsoft][ODBC_SQL_Server_Driver][SQL_Server]Login_failed_for_user_” error for me as well, server is in mixed mode, have a DSN setup with a SQL account that has permissions to the DB. weird thing is this error shows a blank for username

    Reply
    • i figured out my issue, mine was related to i was previously using Windows Environment Variables for my username and password for the connection string. so having those set up again ensured that i could connect and get rid of this login failed for ” error message i was receiving even though i had mixed mode on the DB and the correct DSN information. thanks this article helped me isolate this issue

      Reply
  • Thanks, It really helped

    Reply
  • This error also happens with your SPN is not correct, let’s say you are trying to connect to myTestSqlServer.myDomain.net with Windows Authentication, but if for some reason you don’t have the SPN’s correctly set you will get this error

    Normally you would like to check this running from an elevated cmd
    SETSPN -L

    and you will have a list with all the SPN’s for that account so you probably will see
    myServerNETBIOSName.myDomain.net:1433 <–this can be a high port too, depending on your setup
    myServerNETBIOSName.myDomain.net:mySQLServerInstanceName

    what you want to do now is add the DNS you are trying to connect with, that means
    setspn -S "MSSQLSvc\myTestSqlServer.myDomain.net:1433" "myDomain\theSqlServerServiceAccount"

    Be aware of using the same port that you have in the other entries, don't force a 1433 if that's not the port on your server, won't work :-)

    This should solve your problem with this error
    This will also solve problems when you try to do a linked server that uses the login's current security context

    Reply

Leave a Reply