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

  • I don’t know if my error is the same as everyone else:
    Access 2003 on a Windows Vista Pro PC. Everyone else can access the Access program on their PC but they have Windows xp. I have admin rights.

    Since the user switched to Windows Vista Pro from XP, he gets Microsoft SQL Server Login error:

    Connection failed
    SQLState’28000′
    SQL Server Error 18452
    [Microsoft][ODBC SQL Server Driver][SQL Servr] login failed for user (null). Reason Not asscociated with a trusted SQL Servr Connection.

    He was able to use the Access program before. I did set up the ODBC connection as I always do on everyone else’s pc.

    I also tried to log into the sql server at the prompt with my userid and password as I have admin rights, but I still get the error. I also tried the administrator logon id / pw and still get the error.

    Why can’t he use the Access database on Vista Pro? Is there something I need to download? Is there something I need to update from Microsoft?

    Thanks in advance for any help.

    Reply
  • Sorry, I didnt mention the version of SQL Server we have : 2000

    Reply
  • OK just to update. I didn’t know that the user was not logging into the domain. The user was setup by our IT person to log into the local laptop for some reason.

    Once the user logs into the domain it worked.

    :D

    Reply
  • Hi All,

    while reinstalling the SQL server getting an error like all the components are already installed but there is no components are showing let any one give a solution for this problem.

    Reply
  • To change security authentication mode

    1.

    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    2.

    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    3.

    In the SQL Server Management Studio dialog box, click OK, to acknowledge the need to restart SQL Server.

    Ref: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/change-server-authentication-mode?view=sql-server-2017

    Reply
  • Dim linkTable As TableDef
    Set linkTable = CurrentDb.CreateTableDef(tableName, dbAttachSavePWD)
    linkTable.Connect = “ODBC;Driver={SQL Server};Server=SERVERNAME;” _
    & “Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD;”
    linkTable.SourceTableName = tableName
    CurrentDb.TableDefs.Append linkTable

    Reply
  • Hello Sir ,

    This article was really helpful .
    But I am not able to connect to database from VB.Net using Windows Authentication . I am able to do it using “sa” account . Meanwhile I am also able to get in Sql Management Studio using local as well as sa account .

    Mixed Mode Authentication Used

    In the below code if i change UserId to sa then my task is accomplished .

    Am I missing Something?????????

    Code Used :

    Sub Main()
    Try
    Dim cbs As New SqlConnectionStringBuilder()
    cbs.DataSource = “Franklin”
    cbs.Add(“Initial Catalog”, “Sharepoint”)
    cbs(“Integrated Security”) = False
    cbs.UserID = “Francis”
    cbs.Password = “”
    Dim conn As New SqlConnection(cbs.ConnectionString)
    Console.WriteLine(“Opening Connection”)
    conn.Open()
    Console.WriteLine(“Connection Opened”)
    Console.WriteLine(“Closing Connection”)
    conn.Close()
    Console.WriteLine(“Connection Closed”)

    Catch ex As Exception
    Console.WriteLine(ex.Message)
    End Try
    Console.ReadLine()
    End Sub

    Reply
  • SQLServer running on Win2k3. Ran sysprep to generate a new SID in attempt to fix blue-screen problem with domain authentication (another story…).

    Anyway, since generating the new SID, Windows authentication to SQL Server is broken. The sa account is disabled. I can log in with a read-only SQL user and that is all I can do. The agent won’t start – fails to authenticate as Local System.

    I need to re-initialize SQL security so I can log in via Windows (Administrator). Or enable ‘sa’ somehow. Any ideas?

    Reply
  • I tried to create new users from security login and give the database which allow the user access, but the user could not login from application. I do not know why?

    Ting

    Reply
  • I have developed ASP.net 2005 website. It has connectin with SQL server 2000 SP4. Whwn I run the site from VS 2005, it runs perfactly. But when I upload it on the IIS server (OS Win2000), the SQL server is not getting connected the error is… Not associated with trusted SQL Server connection.

    I have tried will all following options :
    1. Changed the authentication mode to SQL Server and Windows mode with audit option None.
    2. Included Integrated security=SSPI in connection string
    3. Included Trusted_Connection=True in connection string
    4. Tried with user name and password in connection string
    5. Created a new user and assigned dbo.owner permission to the user and provided user id and password in conncetion string.

    Still the error persists.
    Can anyone help me ???

    Reply
  • thank you very much

    this article really help me

    Reply
  • Hello,

    I have an Access 2003 DB with an ODBC connection to a SQL 2000 Server. There are about 4 different people with similar security rights who use this and 3 are able to use the db with no problem.

    One person has the same error as described on this page

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

    This user claims that he usually does not log into the domain but he claims that in this case he was logged in and it still did not work. I submitted a ticket to IT to take a look at his account and they verified that he has admin rights to his PC.

    Do you know why one person would have this error when others with the same security rights do not have problems? Would this indicate a domain issue perhaps?

    Thanks,
    Creed

    Reply
  • Scenario: You are using SQL Server 2005/2008 management studio to connect to a SQL Server. In management studio, you are trying to set up a linked server. When trying to access the linked server, you receive the error message in this plog.

    Problem: Because you are remotely connected to your SQL Server and trying to access a linked server, you are engaged in a double-hop authentication. IE, your credentials are passed to your SQL Server and your SQL server is trying to pass them to the linked server. This requires Kereberos authentication.

    Solution: A domain admin must enabled delegation of your SQL server via Active Directory so your credentials can be passed through.

    Reply
  • i have installed SQL SErver 2000, when i try connect using ‘SQL server authentication’ mode with ‘SA’ or my username, it is giving me 18452 – user not assoiciated with a trusted connection. i noticed ‘Mixed authentication’ mode set to disabled. how should i fix this issue?

    Reply
  • Does anyone know what might cause this error to occur sporadically? I have a service which makes a connection every few minutes to several servers. If the connection fails, I get paged. Once it’s able to connect, I get paged again. This error is occurring randomly on a few of the servers; the service is able to reconnect after a few minutes. So I’ve had many sleepless nights lately!

    Reply
  • Hi Sue,

    I am having similar issues where my application would occassionally lose connection to SQL Server. After a few mins, the connection would be restored automatically but it is definitely cauing problems in the production environment.

    My SQL is clustered but no failover occurred when the connection was lost.

    Anyone can help? Much appreciated.

    SQL Log says:

    Error: 17806, Severity: 20, State: 2.
    2008-11-03 07:54:25.63 Logon SSPI handshake failed with error code 0x80090311 while establishing a connection with integrated security; the connection has been closed. [CLIENT: 10.1.64.44]

    2008-11-03 07:54:25.63 Logon Error: 17806, Severity: 20, State: 2.
    2008-11-03 07:54:25.63 Logon SSPI handshake failed with error code 0x80090311 while establishing a connection with integrated security; the connection has been closed. [CLIENT: 10.1.64.41]

    Reply
  • I am try to use the following script to open some linked tables from an SQL 2005 Server from a client with Access 2003. I can do it manually with no problem, but when running the script I get the following error.

    Could not find installable ISAM

    Can Anyone Help Me Please?

    Option Compare Database

    Private Sub Command0_Click()
    On Error GoTo Err_Command0_Click

    Call LinkToSQL(“dbo_Batch”, “Riegos”, “dbo_Batch”, “AAA”, “sa”, “INFO121”)

    Exit_Command0_Click:
    Exit Sub

    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click

    End Sub

    Sub LinkToSQL(strAccessTable, strDBName, strTableName, strDataSourceName, strUserID, strPassword)
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table

    Set cat = New ADOX.Catalog
    cat.ActiveConnection = CurrentProject.Connection
    Set tbl = New ADOX.Table
    tbl.Name = strAccessTable
    Set tbl.ParentCatalog = cat
    tbl.Properties(“Jet OLEDB:Create Link”) = True
    tbl.Properties(“Jet OLEDB:Link Provider String”) = “OBBC” & _
    “;Database=” & strDBName & _
    “;UID=” & strUserID & _
    “;PWD=” & strPassword & _
    “;DSN=” & strDataSourceName
    tbl.Properties(“Jet OLEDB:Remote Table Name”) = strTableName
    cat.Tables.Append tbl

    End Sub

    Reply
  • I had this problem and was due to account being locked out.

    Reply
  • To change security authentication mode

    1.

    In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
    2.

    On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
    3.

    In the SQL Server Management Studio dialog box, click OK, to acknowledge the need to restart SQL Server.

    Reply
  • Thanks, solved the problem with ease.

    Reply

Leave a Reply