Thursday, May 06, 2010

"Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."

If you are getting the above error while trying to connect to a database, the reason is you are using Windows Authentication to login to the SQL Server while being in another untrusted domain.

For example if the SQL Server machine is a member of the CompanyDomain and if you are in MyDomain or if you are in a Workgroup the you will face the above issue while trying to connect to the SQL Server.

The connection string used in the web.config while the above error is generated is as follows.





  1. <connectionStrings>
  2.   <add name="cnnStr" connectionString="Data Source=BI-SVR;Initial Catalog=BBIDatabase;Integrated Security=True"/>
  3. </connectionStrings>




 

There are three ways to fix this problem.

1. Use the SQL Authentication to login to the SQL Server.

You can get this done by changing the connection string to use SQL authentication while connecting. But you need to know the credentials of an account which is having permissions to your required database or the System Administrator (SA) password. For simplicity I will use SA account details in the connection string.





  1. <connectionStrings>
  2.   <add name="cnnStr" providerName="System.Data.OleDb" connectionString="Data Source=BI-SVR;Persist Security Info=True;Password=YourPassword;User ID=sa;Initial Catalog=BBIDatabase"/>
  3. </connectionStrings>




 

2. Login to your machine using the same Domain.

If you login to your machine using a domain account which the SQL Server is added to, then this error will vanish. But for this you need to add your machine to the same domain which the SQL Server machine is added to (CompanyDomain) also to properly get authenticated the account used should have proper permissions set to access the database in the SQL Server.

3. Make the account trusted in SQL Server.

By making the account you use to login to your machine trusted account in SQL Server and giving it appropriate permissions to access databases will also permit you to fix this error.

6 comments:

THickBox said...

thanks for the infomative post. But how to make an account trusted on sql server?

Anonymous said...

І was able to find good advice from your artіcles.
My blog post - Domainer

Anonymous said...

What's up, always i used to check web site posts here in the early hours in the dawn, as i love to find out more and more.

My weblog spyware free removal

Anonymous said...

Howdy! I could have sworn I've been to this blog before but after reading through some of the post I realized it's new to me.
Nonetheless, I'm definitely delighted I found it and I'll be book-marking and checking
back frequently!

my homepage: rimowa

Anonymous said...

Hi, і thinκ that i saω you ѵisited mу sіte thus i came to “rеturn the faѵoг”.
I am trying to find thingѕ to improνe my site!
I suppose itѕ ok tο use a few of yοuг іdeas!
!

Herе is my ωeb blog: brazilian jeans

Anonymous said...

Wow that was odd. I just wrote an very long comment but after I clicked submit my comment didn't show up.
Grrrr... well I'm not writing all that over again. Anyhow,
just wanted to say excellent blog!

Check out my homepage; people search ()