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
196 Comments. Leave new
I am trying to write a Maintenance Plan history to a remote server. Nothing shows up in the table, and the text log file has the following error.
[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.
I tried running the script at the top of this discussion and keep getting the following error.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ‘LOGIN’.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ‘LOGIN’.
I have checked the login settings in Security via Enterprise Manager, and have also confirmed I can log in using SA.
Any suggestions?
Hi,
Im using msql server 2000. My problem is i cannot connect to my server. I tried all my knowledge but it doesnt work
1. sql network interfaces, error: 26.
please help
Renato
I am still not able to connect, same error.
using sql server 2005 SP2.
I got this error once i had installed .NET Freamework 3.5, athen everything is messup.
can you help me out please?
Hi !!!
Just a simple and wonderful solution. I’m migrating an application on VB6, SQLServer2000 and Windows2000 to a new server (Win2003 Server) and I got this message. I didn’t believe the solution will work, but anyway I tried and it worked perfectly.
Thanks so much from Mexico.
Regards
Yan
Really helped!!
really a big thnx ,i spend 5 hours in it but when i read this it works :)
Hi
I need to connect my C# windows Form to a SqlServer IP which is in same LAN but remote. When I try to connect it says
“error 18452 The user is not associated with a trusted SQL Server connection”
This is the conn string i am using
string strSQLconnection = @”Data Source=107.2.2.10,2230;Initial Catalog=OrderPlacement;Integrated Security=True;User Id=xxx;Password=xxx;User Instance=True”;
Can you pls help?
Thanks
Mohit
Hi,
Is there any way that we can change this authentication mode from windows to mixed using Scripts?
In my case, I don’t want to use the SQLServer Management Console for this change. Because I am keeping everything (includind database creation, user creation, table creation etc) in scripts.
I appreciate your help on this.
Thanks,
Gopal
Hi,
I am using the MS SQL 2005(64Bit) on Windows 2003 64Bit. SQL Server is running on cluster. So time when I restart one of the domain controler , getting the following error. SQL Server has setup on mix mode and has given the correct DNS setting
An Error has occurred in Phoenix2, Version=1.0.3330.29344, Culture=neutral, PublicKeyToken=null
—————————————————————-
System.Data.SqlClient.SqlException: Login failed for user ”. The user is not associated with a trusted SQL Server connection.
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at Phoenix2.mSKFunctions.LogError(LogSeverity Severity, String& Message, String& Details) in C:\Development\Phoenix\Phoenix\Phoenix\mSKFunctions.vb:line 1137
—————————————————————-
Appriciate your grate help on this.
Thanks
Ranjith
I just want to say thank you!
Regards!
Hi Gopal,
try this :
USE [master]
GO
EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’LoginMode’, REG_DWORD, 2
GO
I have a problem with sql server 2005. I have created a web setup project using custom action to create database at installation time. Every thing is ok. It creates prerequisites (.net farmework 2.0, sqlserver 2005 express, etc.) and database successfully during installation. I have used the connection string
connectionString=”Data Source=.\SQLEXPRESS;Initial Catalog=TrainTrack;Integrated Security=true;” in my custom action which executes database script successfully and install web application as well.
But when i execute my application login page and supplies Login Id and Password, It did not connect to sql server on other machine. It works fine on my development machine fine also.
I check my application connection string in ‘Inetpub\wwwroot\Application\web.config, which is also the same as custom action connection string.
I do not understand, actually what’s problem is?
Any one please help me.
Thanks
Ranjith:
This knowledge base article talks specifically about a fix for login errors when the domain controller is restarted:
https://support.microsoft.com/en-us/help/942636/
Thank you!!! Pinal Dave….This article really helped a lot….
Its helpful. Thank u
I have my Server set to SQL Server and Windows Authentication Mode, but I get “Login filed for user ”.
My app settings are as follows:
In my web.config settings, I have the authentication mode defined within as follows:
I have been wrestling with this problem for over a week and still don’t have a solution. My problem seems similar to the others, but I already had the authentication mode set to both Windows and SQL Server.
Can you tell me what I need to do to correct my error?
Thank you very much,
Art
P.S. The error message with stack is as follows:
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 ”.
Source Error:
Line 28: pw = Request.Form(“password”)
Line 29:
Line 30: If UserLogin(reg, pw) Then
Line 31: Response.Redirect(“MainMenu.aspx”)
Line 32: Else
Source File: C:\Users\Art\Documents\Visual Studio 2008\WebSites\WebSite1\Login.vb Line: 30
Stack Trace:
[SqlException (0x80131904): Login failed for user ”.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846887
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.SqlClient.SqlConnection.Open() +122
PC.DbAccessor.GetDR(String cSQL) +127
PC.EDUPage.UserLogin(String aUserName, String aPassword) +176
Login.cmdLogin_Click(Object sender, EventArgs e) in C:\Users\Art\Documents\Visual Studio 2008\WebSites\WebSite1\Login.vb:30
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
I will try another solution
I tried the above script but getting erro
Incorrect syntax near ‘LOGIN’.
Thanks! That fixed it!
Thx, mean while it works.
I have many servers, and one of them is in different network
We just do this
“Frank Stevens
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).”
so..our domain controller (on other network) had virus, virus attacking security system, sometime it grant the active directory and sometime it doesn’t (Aaarrgghh..)
I had the same problem.
SQL 2000 on a server in windows authentication mode.
The Active Directory role set in the SQL security tab.
My colleagues could log on to the server using the enterprice manager. I couldn’t, getting the same error “Login failed for user ‘(null)’. The user is not associated with a trusted SQL Server connection”. Setting the server in mixed mode is no option because of business policy.
The solution:
With the windows explorer I connected to a shared directory on the server.
Problem solved.
I don’t understand why or how, but it works.