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

Some errors never got old. I have seen many new DBA or Developers struggling with this errors.

Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

Fix/Solution/Workaround:
Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)”
to “Mixed Mode (Windows Authentication and SQL Server Authentication)”.

Run following script in SQL Analyzer to change the authentication

LOGIN sa ENABLE
GO
ALTER LOGIN sa WITH PASSWORD = '<password>'
GO

OR

In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties. On the General page, you may have to create and confirm a password for the sa login. On the Status page, in the Login section, click Enabled, and then click OK.

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

SQL Error Messages, SQL Scripts, SQL Server Security
Previous Post
SQL SERVER – Stored Procedures Advantages and Best Advantage
Next Post
SQL SERVER – CASE Statement/Expression Examples and Explanation

Related Posts

196 Comments. Leave new

  • Hello,
    i am using sql server 2005 and installed in mixed mode withe user name sa and password #sa
    and from Sql Server Surface Area Configuration i select the Using both TCP/IP and named pipes for remote settings under Database Engine
    version is [@@version]
    Microsoft SQL Server 2005 – 9.00.1399.06 (Intel X86) Oct 14 2005 00:33:37 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Evaluation Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

    My os is Xp with service pack2

    I am using asp.net 2.0 and using connection string in web.config

    SOURAV is my local Database Server name.

    I can connect server with the user name password from the SQL Server Management Studio,
    But the problem arise when i hit con.open() from asp.net page

    error message show login failed for user ‘sa’

    Please help how to solve,
    Thanks in advance
    Sourav

    Reply
    • I have the same problem, except with php. So have you solved your issue regarding this problem ? Please help.

      Reply
  • the sql server registertration failed user and the two user in different operating system but in the same network group

    Reply
  • I have the same problem, but in my case, changing to Mixed Mode authentication did not fix the problem.

    I can login under Windows Authentication without problem, but any attempt to use SQL Server Authentication results in the “not associated” error.

    I have also tried using the “sa” account, changing “sa” passwords, and even dropping password policy on the “sa” account… no joy. I have also tried creating new users, with explicit server authentication permission and passwords, but still no luck.

    Any suggestions?

    Reply
  • hi
    I am trying to configure log shipping on sql server2000 on a domain with a machine with same sql server 2000 on different domain but i m getting the error :

    Microsoft (R) SQLMaint Utility (Unicode), Version Logged on to SQL Server ‘ANKUR-BZOPEK2PX’ as ‘ANKUR-BZOPEK2PX\sqladmin’ (trusted)
    Starting maintenance plan ‘log_ship’ on 3/18/2008 10:20:00 AM
    [1] Database log_ship: Transaction Log Backup…
    Destination: [E:\backup\log_ship_bakup\log_ship_tlog_200803181020.TRN]

    ** Execution Time: 0 hrs, 0 mins, 1 secs **

    [Microsoft SQL-DMO (ODBC SQLState: 28000)] Error 18452: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.
    [2] Database log_ship: Delete Old Backup Files…
    0 file(s) deleted.

    Deleting old text reports… 0 file(s) deleted.

    End of maintenance plan ‘log_ship’ on 3/18/2008 10:20:00 AM
    SQLMAINT.EXE Process Exit Code: 0 (Success)

    please suggest me
    thankyou

    Reply
  • but still my problem persists,Error:18452;trusted connection

    Reply
  • thanks it solves my problem.

    Reply
  • may you have to chek in the propriete of the server on the consol management sql express the tab securité

    Reply
  • Another thing to check is the information you add to your Add Connection box.

    Make sure you have the correct path of the servername. You may need to do something like this: MYCORPSERVER/SQLEXPRESS

    The wrong path will also give that ugly “Login failed…” error

    Reply
  • hiiii
    i have given the userid as “sa” itself…..and mode of authentication is mixed mode itself……but still i am getting the error…..”login failed for the user ‘sa’ ” while connecting to sql server.

    Reply
  • hai
    thanx for ur help

    Reply
  • Pedro R. Lopez
    May 1, 2008 9:34 pm

    The problem is usually the security tab in the link server.
    use the correct connection setting.
    I always recomend login maping and use the current login security context. hope this help. :-)

    Reply
  • Malhar Vora
    May 2, 2008 4:46 pm

    Really lots of Thanks for this solution.

    I m facing this problem from long time and had no solution.

    This is really working solution which works for me.

    Thank you very much.

    Post this kind of Fixes of error in future.

    Reply
  • Mahesh Perera (SL)
    May 8, 2008 5:43 pm

    Hi,

    Problem:

    I am getting this error when try connecting with SQL server 2000 using Link Servers on XP machine.

    Server: Msg 18452, [SQL Srver]Login failed. Reason: Not associated with a trusted SQL Server connection.

    Solution:

    Corect My DNS (Main Domain) and Change the Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)”
    to “Mixed Mode (Windows Authentication and SQL Server Authentication)”.

    Thanks,

    Mahesh.

    Reply
  • Hi
    Thank you for the solution. I tried many ways to change the authentication mode from Windows to Sql Server Authentication mode. But there is no use. But after trying the above, the problem solved immediately. Thank you for the code.

    Reply
  • hi

    I am using Vista as an OS. I am currently working on VS 2005 and SQL Server 2000. i am tired of working wiht this error and m really screwed up. can u please help??

    Login failed for user ‘Anubhav-PC\Anubhav’.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException:
    Login failed for user ‘Anubhav-PC\Anubhav’.

    Source Error:

    Line 48: cn = New SqlConnection(“data source=localhost;initial catalog=payroll;integrated security=sspi;”)
    Line 49:
    Line 50: cn.Open()
    Line 51: eid = TextBox1.Text
    Line 52: ename = TextBox5.Text

    I have tried creating a new user named ‘anubhav’ and have changed mode to Mixed. Yet the problem persists.

    Please help!!!!

    Thanx in Advance
    Anubhav

    Reply
  • Hello sir,
    I am getting following error when i m creating system dsn for sql server 2005.
    I HAVE ASLO DONE THE AUTHENTICATION MODE FROM WINDOWS TO MIXED MODE.
    Connection failed:
    SQL state: ‘28000’
    SQL server error:18452
    [Microsoft][ODBC SQL server driver][SQL server] login failed for user ‘asdf’. User is not associated with a trusted SQL server connection.

    Reply
  • Hi All
    i am using SQL Server 2005 SP2 mixed mode of authentication is in use still getting this error
    Login failed for user ”. The user is not associated with a trusted SQL Server connection
    Error: 18452, Severity: 14, State: 1.

    any help will be appreciated.
    Regards

    Reply
  • Hi,

    This article is useful but because of some security requirements we have to use windows authentication only. So, i wanted to ask whether there is a possiblity to solve it by using the windows authentication mode.

    Thanks.

    Reply
  • Arun Prasath J
    July 15, 2008 2:33 pm

    Hi All,

    Me also facing this kind of problem. I executed the following sql statement. But still I am getting ”
    ” Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword ‘user’. ”

    while runing this SQL statement. Please forgive me for this silly qstn. I am a new boy to this SQL Server world.

    SQL Statement I executed :
    ALTER LOGIN user ENABLE
    GO

    Thanks
    Arun J

    Reply
  • I have SQL SERVER 2005 (EXPRESS) running on my home desktop machine. However, on this desktop machine there is no Query Analyzer and neither SQL Server Management Studio. It’s my first time to use SQL Server 2005.

    On my office laptop, I have SQL Server Management Studio. When I try to connect to the SQL server on my desktop machine, I get this error.

    Error: 18452 Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection.

    Here is a screenshot of the error I am getting.

    Any help would be greatly appreciated.

    Reply

Leave a Reply