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

  • Your article really helped me – I forgot my ‘sa’ password and your script helped me change it.

    Thanks Again!

    Reply
    • Hi,

      We are having Application running on Local machine and

      database Sql2008R2 with Windows authentication. One

      domain user having issue/ gets untrusted user sql

      connection error manytimes and it works fine for somtime

      when you log off and log back In.

      Error details. Error 18452 (not associated

      with a trusted sql server connection) sql 28000

      Please advise.

      Reply
      • Hi Sukh,
        We are having the same issue here at work in a very similar situation. Were you ever able to resolve the issue? Thanks.
        -Karen
        UCSD

      • No karan, I am still having the same issue.

        I tried many things so far didn;t work.

        Please let me know if you find a solution.

        Thanks

      • Imran Mohammed
        June 1, 2011 8:28 am

        @ Sukh

        Can you provide more details.

        I am not sure why is it happening, but did you check, what is the value set for Maximum No of Concurrent connections at Server Level ?

        You can check this, Right Click Server Name in SSMS, Select Properties, Go to Connections tab.

        Other scenario could be, if you have used that windows Login to run any service, and you recently changed password for that Windows Account but for got to change password at the service logon. Then for every 5 attempts of the service, the Windows Account will be locked because of incorrect password attempt made by the service. And as per Windows Policy Set, Windows Account are reset after some times, (most of the times this will be 30 minutes).

        Try checking if you have used this windows Account in any of the service, if you did then change the password at the service logon to new password of windows account. Checking Event Viewer could give you more information.

        ~ IM.

      • Hi Imran, I have checked it and we assign 0 for unlimited connections.

        Other thing is we are using window authentication for sql2008r2 and we have an application running which uses sql2008 as a backend .

        All the user are domain user using the domain account. It works fine with some users but some user have an issue Error 18452(Untrusted Domain connection).If you log off and Log back in , it starts working fine.

        Please advise

      • Imran, We have only one database SQL2008r2 and the log off is from OS not the application.

        User connect through the application with window authentication.

        Please tell me if you have any question. I am tired of this error.

        Thanks

      • Hi Sukh, Hi All,
        The network – guru’s did finally figure out at least what the problem was we were having. For those of you running on an “authenticated” network this may be useful:
        They changed a few parameters – the ID of which I don’t know – but the basic error message stayed the same.
        The “Fix” that caused the error message to go away and everything to work was to make sure that the UserID and password with which I was signing into my computer – and thus onto the Microsoft Active Domain server – was the same as the UserID and password entered into the Sql2008 database server.

        From what I can understand – I was signing into the AD server and the AD server was signing me in to the SQL server – but it was giving the SQL server my ACTIVE DOMAIN UserID and Password. As soon as the UserID and password being provided to the SQL server matched the UserID and password it was expecting – then it knew me and let me in.

        Hope that help someone –
        Regards,
        Karen RS
        Calit2 at UCSD

    • Hi

      If you are getting this for an AD account then try following

      1) Go to windows security in the server where you get the error and then set a new password from there

      2) If above doesnt work,set it back to old password,login to SQL and logoff from all places and set new password

      Regards
      Rakesh

      Reply
    • error 15118 how to slove help me out …..

      Reply
  • Hi,

    Your article really helped me. I really appreciated that.

    Thanks,

    Manoj

    Reply
  • I am getting this error when try connecting with SQL server 2000 using Query Analuzer on XP machine.

    Server: Msg 18452, Level 16, State 1
    [Microsoft][ODBC Server Driver][SQL Srver]Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.

    Reply
  • Your artical really help me, when I am trying this in the production. Because I wrongly selected Authentication Mode of the SQL server from “Windows Authentication Mode (Windows Authentication)” with the help of your script I have change to “Mixed Mode (Windows Authentication and SQL Server Authentication)”, its work out…

    Reply
  • Rizwan Ansari
    June 27, 2007 3:57 am

    Hi,
    why should I change the authentication??
    Actually, I am trying to run a query thru linked server. I linked the server by windows login and my target SQL server is running under windows authentication only and I am getting the same error.

    Please clear my doubt why should we use only mixed mode? Why it is not working with windows authentication, even I am using a domain account to connect?

    Reply
    • I had a similar kind of problem, finally this give me clue, that one of the linked server do not have authentication rights for the user so when I execute the view I was getting error invalid login

      Reply
  • I am using linked server and getting same error when trying to access linked server. I have Server1 with linked Server2. I am connected to Server1 using management studio remotely and trying to access linked server Server2. If I connect locally to Server1 and try to access linked Server2 this works. Any help will be appreciated.

    Reply
  • Hi,

    Things were working quite happily locally on my machine with Windows Authentication .. I tried setting up an ODBC connection to the database; this did not work

    Upon trying to reaccess the database, via SQL Server Management Studio, the system reported, “Login failed for user . The user is not associated with a trusted SQL Server connection”

    Luckily I was able to connect using 127.0.0.1 rather than my machines DNS name and was able to create the sa account to regain access. How is it then that I re-enable Windows Authentication mode?

    Thanks

    mrplatypus ..

    Reply
  • Frank Stevens
    August 3, 2007 8:17 am

    This is for WINDOWS AUTHENTICATION:

    I received this error when connecting to the SQL Server remotely via my application. After researching, I found that you had to both enable trusted authentication on my SQL Server machine and grant the User Right “Enable computer and user accounts to be trusted for delegation” (Group Policy…under Local Policies\User Rights Assignment) to the Windows account you are using. I just granted it for the Administrators group.

    For the SQL Server machine, I set the property in Active Directory (check the box labeled “Trust computer for delegation” in the computer’s properties).

    Make sure you for the group policy changes (gpupdate /force).

    Reply
  • I have clustered SQL 2005 Enterprise 64 bit and SQL 2005 SP2 on a Windows 2003 server and I can log in fine with domain credentials, but not with ‘sa’. SQL is installed in mixed auth mode and has all the default protocols, including Named Pipes and TCP/IP. I get error 18452 and I have read many, but not found any articles or discussions on the Internet or from Microsoft that solves the problem. My head hurts.

    Any help is appreciated.

    Reply
  • I’m trying to switch from windows authentification mode to sql server authentification.

    Have doen all as you’ve written.

    and it still gives me error Error 18452 (not associated with a trusted sql server connection)

    Reply
  • Frank Stevens, could you be more specific, where to change theese policies and other things form you post.

    Reply
  • Are there any problem if the server is on different network than client?
    In my scenario my client is working into a network without Windows servers (so any AD is running or required for validation) but the SQL server (that is an SQL server 2000 SP3 running on a Windows 2003 server R2) is into another network WITH AD.
    The connection is transparent through router. All other network services runs fine between both networks.
    I’ve followed all steps but I’m still having the same problem.
    2 clients running same OS with same ODBC have different behaviors. The client connected on same server’s network runs fine but the other one raises this error.

    Any help will be appreciated

    Reply
  • Please check the Server name is in Sink with server name of SQL Server. The host name should be the same as
    Select @@Servername. If they are not the same, then use SP_Dropserver ‘oldServername’ and then Supply SP_addserver ‘Servername’,’Local’. then restart the server (OS) to take effect.

    Reply
  • sql express05 does allow me change password when
    iam logged with windows authentification,on next restart doesnt allow me to login with sa(by the way it shows some long password with asterixs).meaning it is not changing the password and
    reports below error.this is LOG
    TITLE: Connect to Server
    ——————————
    Cannot connect to BLEEDING-DESKTO\SQLEXPRESS.
    ——————————
    ADDITIONAL INFORMATION:
    Login failed for user ‘sa’. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
    —————–
    any way to change to mixed mode authentification?

    Reply
  • This is nice work around .

    It helped me ‘N’ times .. i did it several times on several times ..for got the solution referred this article and got back to work and implemented it .

    Thanks
    Ravi Srinivas

    Reply
  • Hi,

    I fogtot to create sa authentication mode at the time of installation. How to create sa authentication. Is it possible at this time. I am able to access windows authentication only. Pl

    Reply
  • I have an ASP.NET 2.0 Application on machine A. I am using forms authentication with Active Directory. My SQL 2K database is on machine B. On machine A, I can access my application, with no problem. When i try to access the application over the network from different machines, i get this error.

    Server Error in ‘/EXACT-WHRM’ Application.
    ——————————————————————————–
    Login failed for user ‘sa’. Reason: Not associated with a trusted SQL Server connection.
    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 ‘sa’. Reason: Not associated with a trusted SQL Server connection.
    ======================================

    please help. am at my wits end.

    moseti

    Reply
  • I discovered that I had to restart the Sql Server service on my local machine to allow sql server authentication to work.

    Reply
  • thank u very much for your article…
    it really helping me

    Reply
  • I am finding the issue while try to connect/create database in SQL Server 2005 from different application.

    Login failed for user ’’. Reason: Not associated with a trusted SQL Server connection.

    I tried with the above mentioned but it is failing to connect.

    Pointers please.

    Regards,
    Dev

    Reply

Leave a Reply