Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

The last few days have been a little bit hellish.  I've been on-site at my client's office helping them do a Windows 2000 to Windows 2003 migration, set up their new server, and deploy beta versions of the applications that I've been writing for them. 

I backed up their SQL Server database from the old server and restored it onto the new Windows 2003 server.  It restored fine.  I could connect using Query Analyzer and any ADO.NET-based application that was running locally could connect.  It's looking good then we start testing some ASP.NET apps that are on a different machine and hit this new database server.  BLAM!  We started getting exceptions.  Either “Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection” or “Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.” 

First order of business: go to google and start digging.  Very quickly I found this tech support article saying that SQL Server isn't set to “mixed mode” authentication.  I checked it out and the sysadmin had installed SQL Server to “Windows only“ mode.  That's easy enough to change.  Changed it and restarted the MSSQLSERVER service. 

No love.  Now I start wondering if there's something messed up in the registry.  I find this article describing how to manually change SQL Server to “mixed mode.”  Nope.  That's already done.  The documentation says that we only have to cycle the instance for the change to take but we reboot the whole server just to make sure. 

Still nothing.  At this point, we've burned up a lot of time on something that should be totally easy.  Now I start wondering if it's a security problem because I kinda half remembered reading about distributed transaction problems between Windows 2000 and instances of SQL Server running on Windows 2003. 

None of it was really looking likely and at some point I started thinking about how SQL Server isn't supported on Windows 2003 under a certain service pack level.  What service pack is this server running anyway?  So, I fired up Query Analyzer and ran “SELECT @@VERSION“.  The version was “2000.80.194.0“.   Quick skim of the build numbers listed online and...UNBELIEVABLE!  This thing hasn't been patched even ONCE!

So, I upgraded to SQL Server Service Pack 4 and my problems went away.  While I was at it, I also turned on Windows Update and found out that none of the security patches had be applied either.  Doh.

-Ben

 

 

posted @ Thursday, June 16, 2005 7:36 PM

Print

Comments on this entry:

# Database call to 'ConnectionWrite (send()).' caused an exception.

Left by Here's some stuff that I like. at 6/16/2005 8:30 PM
Gravatar

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Ravi Kiran at 7/4/2005 9:07 AM
Gravatar
Thanks, it helped.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Madmax at 11/22/2005 2:58 PM
Gravatar
Completely fixed my issue using sql 2000 Enterprise with 2003 server using VMware ..

I have been trying to access my SQL server using a bridged connection on VMware which gave me the error:- Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

If you happen to know much about about importing SQL data into excel using VB.. this is what i've just spent three hours sorting the above little gem to prepare for :)..

Cheers

Madmax

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Vasasnth T T at 1/10/2006 10:58 PM
Gravatar
thanks dude.. it really helped me

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Amit at 3/1/2006 5:44 AM
Gravatar
hi
this is amit jha.
iam going through this problem when iam trying to connect to SQL-SERVER2000 which is running in clustered mode
please help me out

thanks and regards
Amit

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Benjamin Day at 3/1/2006 8:15 AM
Gravatar
Are you sure that you're connecting to the cluster's address and not the individual server? Have you run all the latest service packs?

-Ben

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Rachel at 3/20/2006 3:21 PM
Gravatar
I justed moved our database to a SQL 2005 running in Windows server 2003. I had the same problem as you did, and changing the authentication mode to "mix" didn't help. Any clue?

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by ron litzenberger at 5/24/2006 5:19 PM
Gravatar
UNBELIEVABLE! is right. I mean its 2006 and I just came across this exact thing. Man, what a difference SP4 makes. :)

Thanks.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Rajnish Tiwari at 7/2/2006 10:12 PM
Gravatar
Dear Janane wale,

plz solve this problem re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.


Regards
Rajnish Tiwari

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by peter jones at 8/24/2006 2:56 AM
Gravatar
Fantastic. Yours was the only article I found on the web that actually addressed the problem.

Many Thanks!

Peter Jones

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by THORN at 10/24/2006 2:04 AM
Gravatar
I try to connect to SQL Server 2000 on the Network by using ASP. I already run mixed mode, and I am running MSDE on Windows XP. The above problem happen, Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
Please help.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Vivek at 11/18/2006 12:46 AM
Gravatar
Cool Ben! It precisely solved my problem of sa login access. All you need is Mixed Mode setting on SQL Server & SP4 installation. In SP 4 installation I chose SQL server Authentication and provided pwd for sa. One more info from my side. “SELECT @@VERSION“. gives (Build 3790: Service Pack 1) in SQL query analyser opst SP4 installation, could not understand much but ok, my login problem is solved and i am happy! Thanks again Ben!
Cheers!
Vivek.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Satheesh at 12/26/2006 2:18 AM
Gravatar
We changed the domain name of the server and i am getting this problem. Service pack 4 is installed and sql server is in mixed mode only.
Please help.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Ravi at 1/3/2007 8:30 PM
Gravatar
Hi I am using SQL server 2005 I can run every thing on server but when I am using it with ASp.Net its giving error "Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection." please help on this

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Benjamin Day at 1/4/2007 5:10 AM
Gravatar
Ravi,

What have you tried so far? Have you checked the settings outlined in this post?

-Ben

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Cathy at 1/16/2007 12:56 PM
Gravatar
I am getting this error and we have Service Pack 4 Build 2195. Any ideas? Help!

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Benjamin Day at 1/16/2007 1:22 PM
Gravatar
Cathy,

Could you post some more details about what you're doing?

Thanks,
-Ben

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by A. Putnam at 1/23/2007 9:16 AM
Gravatar
hi ,

We are running SQL server 2005 - 9.00.1399.06 on Server 2003 Enterprise Edition SP1. I started receiving error mesage "Login failed for user " (null). The user is nor associated with a trusted SQL server connection."

SQL is running in mixed mode, but I never define sa password.

Could the the problem start after i installed the most recent MS updates KB929969, 926247,923689, 923694, 925454, 911897, 922760. Other than updates above, I do not remember changing anything on the server.

Ana

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Benjamin Day at 1/23/2007 9:18 AM
Gravatar
A Putnam,

Could you post or email me the connection string that you're using?

-Ben

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by A Putnam at 1/23/2007 11:15 AM
Gravatar
I know it sounds terrible, but how do i get to the connection string?

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by A. Putnam at 1/24/2007 8:01 AM
Gravatar
Ben,

here si the connection string:

Provider=SQLNCLI.1;Data Source=SERVER;Integrated Security=SSPI;Initial Catalog=CATALOG_NAME

Ana

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by tanmaya at 2/9/2007 9:17 PM
Gravatar
i have faced the problem. login failed for user 'sa'. Reason : Not associated with a trusted SQL Server Connection. Here see my Connection String
dim con as new sqlconnection("user id=sa; database=tanmaya; server = local host")

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by James Avery at 2/22/2007 7:44 PM
Gravatar
Thank you Ben!!!!

I am new to the sql server world and sql for that fact. I am staying late nights into the wee hours to keep my job.

This will get me a few nights sleep and maybe the weekend off (ok not that much)

Let me know if I can ever return the favor

james.avery@monster.com

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by ashfaq at 3/30/2007 10:31 AM
Gravatar

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by kahin at 4/8/2007 11:53 AM
Gravatar
thank you!!it help me

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Hiral at 4/22/2007 2:35 AM
Gravatar
Hi,

I am working with .NET web application... here with Connection string if i am passing "Initial catalog= TempDB; Data source = (local)", here it is not able to connect with server and it gives me message...

Hiral

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Ben Day at 4/22/2007 4:59 AM
Gravatar
Hiral,

Try changing your connection string to
"Initial catalog=TempDB;Data source=(local);Integrated Security=true"

-Ben

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by linda at 6/14/2007 6:40 PM
Gravatar
this is my connection string

SqlConnection = New SqlConnection("server=hdmycsdpt20045;uid="";pwd="";database=Test")

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by vaibhav at 6/22/2007 4:09 AM
Gravatar
i also having the same problem of "login failed for user 'sa ' is not the trusted sql server connection ms sql server error 18452"") imm using sql server 2005 ......can ane one help me out

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Gayathri at 7/5/2007 8:13 AM
Gravatar
thanks for eresolving it is fanatastic

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by mik at 7/10/2007 2:44 AM
Gravatar
when i change new password,also the same of this,but i change back old password in nt , it is good.

#  Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by pradeep at 7/25/2007 7:26 AM
Gravatar



i also having the same problem of "Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.") imm using sql server 2000 ......can ane one help me out

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Harvey Dalmacio at 8/4/2007 3:42 AM
Gravatar
Sir Ben, I want to say THANK YOU for this forum. I was experiencing same problem as yours but its solved now :) thanks sir.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Diego at 8/7/2007 1:10 PM
Gravatar
The link to MSSQL Server SP4 download has changed from this...
http://www.microsoft.com/sql/downloads/2000/sp4.asp

... to this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=8e2dfc8d-c20e-4446-99a9-b7f0213f8bc5&displaylang=en#filelist

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Shrikanta at 8/22/2007 3:00 AM
Gravatar
I am also having the same problem:
Cannot open database requested by the login. The login failed. Login failed for user 'sa'.
Database: SQL Server 2005
OS: Windowserver 2003 : SP-2

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Alan at 8/24/2007 7:48 PM
Gravatar
Here's a different kink to this same problem. I wrote a Windows App that connects to the sql server. When the program starts, all is well. No connection problems UNTIL they walk away from their computer for about 5 minutes or more with the program running. The next time the Prg accesses the database, Cannot open the database. Login failed OR If I'm using Integrated I get the cannot generate SSPI.... Any ideas?

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Ben Day at 8/25/2007 6:32 AM
Gravatar
Alan,

"Cannot generate SSPI" sounds a little like the client cannot access the Active Directory domain for some reason.

Did the user connect via VPN, run the app, then turn off the VPN?

Is there any chance that you were leaving the connection open and that the connection has timed out in some way between requests?

Like almost any response I'd give to questions in this thread, these are largely just wild guesses. Hopefully, they'll trigger some "ah ha!" moment. :)

-Ben

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Alan at 8/26/2007 10:06 AM
Gravatar
Thanks for the response Ben. It's not using a VPN connection. I had thought the same thing about leaving a connection open and checked all that... I kept thinking, why can I NOT recreate the same problem on my test system. I even left the Prg running overnight and no problem. After reading the above comments, questions, etc. I checked a little further into what the difference could be. The only difference was tht my test system's SQL was set to Windows and SQL Auth. I checked the system where I actually installed the live version of the Prg. That system was set to Windows Auth. Now from what I read above, I should have been getting this error evey time I started the Prg. I won't know until tomorrow if the change to Windows and SQL made a difference but hopefully that was the problem.

Will let you know if it worked and Thanks for the Ah Ha! moment!

Alan

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Oliver M. at 9/7/2007 12:32 PM
Gravatar
Thank you Ben...

Solved my problem.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Vishwanathan at 9/25/2007 3:01 AM
Gravatar
I am not able to acces the database, the problem says re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
well allthough i have entered the trusted_connection=true and integreted security = true or sspi
but still it says the same problem.and i have given username and password also
please help me

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by max at 12/10/2007 11:49 AM
Gravatar
Thank you very much. I knew there was a disconnect somewhere, but drew blank until I read this post. I always install SQL Server 2005 using mixed mode, but this time someone did it for me. Oh well, Windows Authentication Only is a bad practice. Fixed!

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Arvind singh Kushwaha at 12/15/2007 11:53 AM
Gravatar
hi

I am having sql server 2000 .I has been installed without any problem . I have developed a project in VB.Net 2003.There is no problem to connect the SQL Server 2000 where it is developed . But in another System it give an error when i go to connect by my project's login and password as:-re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
Please help me

thanks
Arvind

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Sourav at 3/4/2008 12:11 AM
Gravatar
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
<configuration>
<appSettings>
<add key="brian" value="server=SOURAV;uid=sa;pwd=#sa;database=test"/>
</appSettings>

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 fauled for user 'sa'

Please help how to solve,
Thanks in advance
Sourav

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Dan at 4/10/2008 9:01 AM
Gravatar
The solution that worked for me on a Workstation running MSDE was to change the following registry entry: (set loginmode = 0)

HKLM/Software/Microsoft/MSSQLServer/MSSQLServer/loginmode = 0

This sets it to Windows Authentication Mode.

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by raju at 4/17/2008 7:33 AM
Gravatar
hi,
my web server in windows xp and running with php 5+apache
and my database server in windows xp or windows server 2003(i try on both os) .i try to connect via odbc from php with database server (ms sql server 2000.)but always i get this error message.
ms sql server intalled on both mode windows and sql.do u have any other idea

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Fernanda at 5/2/2008 11:41 AM
Gravatar
Thanks a lot! you saved me !

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Asan at 5/5/2008 2:10 AM
Gravatar
When U R facing problem to connect the data base, please check the connection as follow
"Server = Servername;Initial Catalog = Database Name;Integrated Security = SSPI"
and Don't forget to add the user in database

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Deepak Yadav at 5/30/2008 1:34 AM
Gravatar
Dear Janane wale,

plz solve this problem re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.


Regards

Deepak Yadav

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Erum Raza at 7/25/2008 4:25 PM
Gravatar
ReAlLy WoRkS,,,,,,

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Lineker at 8/19/2008 4:43 PM
Gravatar
It really works.... perfect...

tks man!

# re: Problem: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Left by Pheakavoin Vong at 8/26/2008 10:25 PM
Gravatar
Hi, thank you a million. It really useful and helpful indeed.

Your comment:



 (will not be displayed)


 
 
 
Please add 6 and 4 and type the answer here:
 

Live Comment Preview: