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

  • hi
    thank you
    very much 4 this articles its really work

    thanks once again……………………………….

    Reply
  • Thanks a lot for your article, as always it’s help me to solve The Problem. I really appreciated your articles.

    Thanks,

    kosxxx

    Reply
  • Hi , I have some problem in my maintenance plan
    The error is ..

    The Execute method on the task returned error code 0x80131904
    (A network-related or instance-specific error occurred while establishing a connection to SQL Server.
    The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server
    is configured to allow remote connections. (provider: TCP Provider, error: 0 – No connection could be made
    because the target machine actively refused it.)). The Execute method must succeed, and indicate the result
    using an “out” parameter. End Error Warning: 2010-02-15 10:41:09.83 Code: 0x80019002
    Source: OnPostExecute Description: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.
    The Execution method succeeded, but the number of errors raised (2) reached … The package execution fa…
    The step failed.

    Please help me ..
    Thanks & Regards ,
    Sahasra….

    Reply
  • Hi,

    Your article really helped me. I really appreciated that.

    Thanks,

    FCruz.

    Reply
  • pankaj pandey
    June 3, 2010 3:04 pm

    hi

    I have install sql 2005 in windows authentication now i want to connect with Server authentication but i can not connect i have create user with Server authentication

    error code is 18452

    Plz help me

    Reply
  • From my experience with this issue, the real solution is to ensure that the Windows account that the client is using to connect to the SQL server has been assigned “Access this computer from the network” rights in the Computer Config\Windows Settings\Security Settings\Local Policies\User Rights Assignment part of the group policy that applies to the computers in the domain where Windows authentication is being attempted.

    Moving to Mixed Mode is a work around. As best as I can tell, when you go to mixed mode, the client uses the Network Service account to connect to the SQL sever, and passes through the SQL credentials. However when you use Windows authentication, it uses the context of the logged in user to make the initial contact with the SQL server (before attempting to log in to the SQL database itself) and if the Windows account does not have the right to even access the SQL server computer on the network, then the request is rejected. Hence the username (null) in the response.

    Some of this is just guessing, but what I know for sure is that I was getting the (null) error using Windows only authentication, and setting up a GPO to allow the user account from the client to access the SQL sever computer from the network fixed it.

    Reply
  • After changing to Mixed mode, restarting the SQL Server is a must to login with sa.

    Reply
  • Hi All,
    If you do all ways that mentioned above and after than your problem does not solve, You look at your sql server Configuration Tools, and notice to your sql server services such as SQL Server Browser is running.
    if it’s not running or you can not runnig it, you can use this help:

    Regards,
    Alex

    Reply
  • Hi ,

    Can anyone explain the internal procedure how the Client connects to the SQL Server using Windows Authentication?

    I have two SQL 2005 servers A and B in two different windows 2003 servers . I have changed the IP of A server to point to B in the DNS and Flushed the resolver cache. Then connecting to the SQL server A is pointing B if the client is on another machine. Bu tif I connect to the SQL Server A from the B machine it is giving the following error:

    “Login failed for the user . The user is not associated with a trusted SQL Server Connection. (Microsoft SQL Server Error: 18452)

    Found this error in the SQL ERROR LOG:

    “Logon SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 10.0.14.11]
    Logon Error: 18452, Severity: 14, State: 1.
    Login failed for user ”. The user is not associated with a trusted SQL Server connection. [CLIENT: 10.0.14.11] ”

    Is there any workaround for this?

    Reply
  • Hi
    I am getting an below error while i try to save the data. using ASP classic with SQL Server 2008 R2

    Microsoft OLE DB Provider for SQL Server error ‘80040e4d’

    Login failed for user ‘WajClt\Imran’.

    /makhazin/savePassword.asp, line 9

    1. Server Name = WajClt-L03\sqlexpress
    2. User Name = WajClt-L03\imran
    3. Password= “”; password is empty

    below is my Connection string
    =========================

    Please help me out?

    Reply
  • Microsoft OLE DB Provider for SQL Server error ‘80040e4d’

    Login failed for user ‘WajClt\Imran’.

    /makhazin/savePassword.asp, line 9

    here is the Connection string
    =========================

    Please help me out?

    Reply
  • below is my Connection string
    =========================

    Please help me out?

    Reply
  • Hi
    I am getting an below error while i try to save the data. using ASP classic with SQL Server 2008 R2

    Microsoft OLE DB Provider for SQL Server error ‘80040e4d’

    Login failed for user ‘WajClt\Imran’.

    /makhazin/savePassword.asp, line 9

    1. Server Name = WajClt-L03\sqlexpress
    2. User Name = WajClt-L03\imran
    3. Password= “”; password is empty

    below is my Connection string
    =========================

    dim cn
    set cn = Server.CreateObject(“ADODB.Connection”)
    dim cnStr

    cnStr = “Provider=SQLOLEDB; Data Source=WajClt-L03\sqlexpress; Initial Catalog=empdata; User ID=WajClt-L03\Imran; Password=;”

    set Session(“cn”) = Server.CreateObject(“ADODB.Connection”)
    Session(“cnStr”) = cnStr

    Please help me out?

    Reply
  • Hi everyone..

    If your problem is “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.”

    Please follow the next steps:
    1. In Object Explorer, right-click on your server\instance.
    2. Click properties.
    3. Select “security” option.
    4. Then, select “SQL Server and Windows Authentication mode”.
    5. Finally, click OK.

    After the last steps, now you can do the steps released by pinaldave.

    jjejjejje=)

    Reply
  • Wow, your solution is to change authentication rather than fix the problem? Wow!

    Reply
  • Thiruneelakandan
    September 21, 2010 5:58 pm

    Dear sir,
    Still I am not able to fix this error 18452

    Reply
  • Could you please help me i see error 26 when i try to login(A metworl related or instance-specific error occured while establishing a con. to sql server)

    Reply
  • Hi everyone

    I have this problem with Microsoft SQL Server
    Connection failed:
    SQLState: ‘28000’
    SQL Server Error: 18456
    [Microsoft][SQL Native Client][SQL Server]Login failed

    Please help me out?

    Reply
  • Thanks. You helped a lot :)

    Reply
  • I’ve has this problem a long time a go, at last solved !!!

    thx

    Reply

Leave a Reply