The login is from an untrusted domain and cannot be used with windows authentication

I am trying to host a SQL server database, but whenever I try to connect to it I get this error:

The login is from an untrusted domain and cannot be used with Windows
authentication

I am connecting through Matlab using the following command:

conn = database('Clinical_Data','DoyleLab07\Acc','','com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://DOYLELAB07\SQLEXPRESS:54287;database=Clinical_Data;integratedSecurity=true;').

Connecting to the database using matlab worked fine as long as I was using matlab on the computer which I was using to host the server. However, when I use another computer and the same Matlab command I get the error I showed above.

When I look under control panel\system. I notice that no domain is listed on my host PC or the PC I am using to connect to the host, but both computers are in the same workgroup. Would I be able to fix my problem by creating a domain and adding the foreign PC and the host to that domain? If so, how can this be accomplished?

Any suggestions will be very much appreciated.
Thank you for reading my post.

NotMe's user avatar

NotMe

87.4k27 gold badges171 silver badges245 bronze badges

asked Sep 4, 2013 at 0:46

Gaven's user avatar

2

Getting rid of Integrated Security=true worked for me.

JasonMArcher's user avatar

JasonMArcher

14.3k22 gold badges56 silver badges52 bronze badges

answered Aug 27, 2014 at 18:02

Shahid Miah's user avatar

Shahid MiahShahid Miah

5934 silver badges2 bronze badges

4

In order to use Windows Authentication one of two things needs to be true:

  1. You are executing from the same machine as the database server.
  2. You have an Active Directory environment and the user the application is executing under (usually the logged in user) has rights to connect to that database.

If neither of those are true you have to do one of two things:

  1. Establish a Windows Domain Controller, connect all of the relevant machines to that controller, then fix SQL server to use domain accounts; OR,
  2. Change SQL server to use both Windows and SQL Server accounts.

By FAR the easiest way is to change SQL Server to use both Windows and SQL server accounts. Then you just need to create a sql server user on the DB server and change your connection string to do that.

Best case option 1 will take a full day of installation and configuration. Option 2 ought to take about 5 minutes.

answered Sep 4, 2013 at 1:40

NotMe's user avatar

NotMeNotMe

87.4k27 gold badges171 silver badges245 bronze badges

4

If your SQL Server is on one domain controller and you are trying to connect to it from another domain controller then you will get this error when

IntegratedSecurity = true;

This will happen even if you include a valid SQL Server username and password in your connection string as they will automatically be over-written with your windows login and password. Integrated security means simply — use your windows credentials for login verification to SQL Server. So, if you are logged in to a different domain controller then it will fail. In the case where you are on two different domain controllers then you have no choice but to use

IntegratedSecurity = false;

Now, when Integrated security is false SQL Server will use the SQL Server login and password provided in your connection string. For this to work, the SQL Server instance has to have its authentication mode configured to mixed mode, being, SQL Server and Windows Authentication mode.

To verify or change this setting in SQL Server you can open the SQL Server Management Studio and right-click on your server name and then select Properties. On the pop-up that appears select Security and you will see where to alter this setting if you need to.

answered Jul 28, 2016 at 19:10

Jay's user avatar

JayJay

5485 silver badges11 bronze badges

2

I’ve had this same issue when using DNS aliases and hosts files to connect to a machine using a different domain name.

Say you have a SQL server called sql1 on mydomain.com — which is an Active Directory domain — and you also have a DNS zone for mydomain.net, and — for consistency — you set up a DNS alias (CNAME) record for database.mydomain.net --> sql1.mydomain.com

You’ll be able to connect to sql1.mydomain.com using Windows integrated security, but won’t be able to connect to database.mydomain.net even though it’s the same server because the domain name doesn’t match your AD domain.

answered May 27, 2015 at 19:51

Dylan Beattie's user avatar

Dylan BeattieDylan Beattie

53.7k35 gold badges130 silver badges197 bronze badges

1

This error message can also occur if the account you are using to access the SQL server is locked out by the domain.

answered Apr 6, 2015 at 16:58

GWLlosa's user avatar

GWLlosaGWLlosa

24k18 gold badges80 silver badges116 bronze badges

2

As mentioned here, you might need to disable the loopback

Loopback check can be removed by adding a registry entry as follows:

  • Edit the registry using regedit. (Start –> Run > Regedit )
  • Navigate to: HKLM\System\CurrentControlSet\Control\LSA
  • Add a DWORD value called “DisableLoopbackCheck” Set this value to 1

answered Feb 13, 2019 at 15:48

Miguel Febres's user avatar

Miguel FebresMiguel Febres

2,1532 gold badges22 silver badges31 bronze badges

If you using windows authentication make sure that password of the user hasn’t expired. An expired password can explain this error. This was the problem in my case.

answered Apr 9, 2019 at 9:19

S3minaki's user avatar

S3minakiS3minaki

2973 silver badges19 bronze badges

Why not use a SQL Server account and pass both the user name and password?

Here is the reason why.

In short, it looks like you have an authentication issue.

The problem with workgroups is there is no common Access Control List like Active Directory (AD). If you are using ODBC or JDBC, the wrong credentials are passed.

Even if you create a local windows account (LWA) on the machine (SE) that has SQL Express installed (SE\LWA), the credentials that will be passed from your client machine (CM) will be CM\LWA.

Richard Marskell - Drackir's user avatar

answered Sep 4, 2013 at 1:17

CRAFTY DBA's user avatar

CRAFTY DBACRAFTY DBA

14.4k4 gold badges26 silver badges30 bronze badges

Same Error with Connection String in Visual Studio dev environment

Our development database server was recently given a self-signed certificate so it automatically became untrusted. This resulted in the login error cited above. I added TrustServerCertificate=True to my connection string and it works now.

"Server=TheServerAddress; Database=TheDataBase; User Id=TheUsername; Password=ThePassword; TrustServerCertificate=True"

NOTE: This certificate configuration is not recommended for production environments.

answered Feb 22, 2022 at 22:46

Tyson Gibby's user avatar

Tyson GibbyTyson Gibby

2,7302 gold badges19 silver badges37 bronze badges

i removed Integrated Security=true and Trusted_Connection=True both of them , worked for me..

answered Feb 15, 2022 at 9:07

Rasool Aghajani's user avatar

In my case the Aliases within SQL Native Client 11.0 Configuration were pointing to invalid server/IP. Once updated it worked correctly.

To check:
1. Start «SQL Server Configuration Manager»
2. Navigate to «SQL Native Client 11.0 Configuration» and then «Aliases»
3. Ensure «Alias Name» and «Server» match correctly for TCP/IP

Ahmad's user avatar

Ahmad

5,5718 gold badges41 silver badges57 bronze badges

answered Oct 18, 2016 at 12:24

user4109297's user avatar

Following worked for me to get access from another machine to SQL Server using Windows Authentication. This approach may be useful only in development/test environment. E.g. you need to update password manually once you change it on your working machine.

On machine with SQL Server go to Control Panel and add new Windows User with same username and password as is on your working machine. Then create SQL Server login for this user:

CREATE LOGIN [SQLSERVERHOST\myuser] FROM WINDOWS;

Now you can use this login for Windows Authentication.

If you receive error ‘The login is from an untrusted domain’, this may mean that you changed password on your working machine and now need to update password on SQL Server machine.

answered Nov 30, 2018 at 9:51

ganisimov's user avatar

Just adding my suggestion for a resolution, I had a copy of a VM server for developing and testing, I created the database on that with ‘sa’ having ownership on the db.

I then restored the database onto the live VM server but I was getting the same error mentioned even though the data was still returning correctly. I looked up the ‘sa’ user mappings and could see it wasn’t mapped to the database when I tried to apply the mapping I got a another error «Fix: Cannot use the special principal ‘sa’. Microsoft SQL Server, Error: 15405». so I ran this instead

ALTER AUTHORIZATION ON DATABASE::dbname TO sa

I rechecked the user mappings and it was now assigned to my db and it fixed a lot of access issues for me.

answered Mar 4, 2019 at 15:22

Barry's user avatar

BarryBarry

213 bronze badges

Joining a WORKGROUP then rejoining the domain fixed this issue for me.

I got this error while using Virtual Box VM’s. The issue started to happen when I moved the VM files to a new drive location or computer.

Hope this helps the VM folks.

answered Feb 25, 2021 at 15:52

Andrew Titus's user avatar

We now use a privileged account management solution that changes our passwords regularly. I ended up receiving this error after my password was changed. Closing and re-opening SSMS with the new password resolved my issue.

answered May 31, 2019 at 13:34

Sam Bryant's user avatar

I started to get this error when i tried to login to SSMS using ‘windows Authentication’. This started to happen after i renamed the Windows SQL server. I tried everything to resolve this error and in my particular case changing the machine names in the ‘hosts’ file to reflect the name SQL server name change resolved the issue. C:\Windows\System32\Drivers\etc\hosts

answered Jun 19, 2019 at 11:28

KASTEER's user avatar

I had this problem because we where using a DNS name from an old server, ponting to a new server. Using the newserver\inst1 address, worked. both newserver\inst1 and oldserver\inst1 pointed to the same IP.

answered Jul 16, 2019 at 11:48

Luis Assuncao's user avatar

Yet another thing to check:

We had our nightly QA restore job stop working all of a sudden after another developer remoted into the QA server and tried to start the restore job during the middle of the day, which subsequently failed with the «untrusted domain» message. Somehow the server pointed to be the job’s maintenance plan was (changed?) using the ip address, instead of the local machine’s name. Upon replacing with the machine name the issue was resolved.

answered Sep 23, 2019 at 14:24

RIanGillis's user avatar

RIanGillisRIanGillis

6191 gold badge6 silver badges15 bronze badges

TLDR: Changing the DNS server to the loop back address worked for me.

I am working in VirtualBox and had setup two Windows Server 2016 instances. Server A is configure as a Domain Controller and Server B as an SQL Server. After adding Server B to the domain I cold not connect to with Management Studio from Server A. I was getting the «The login is from an untrusted domain and cannot be used with Windows authentication».

My initial configuration had the server getting its IP from the VirtualBox DHCP server.

I changed this to use static IP and entered the 127.0.0.1 address in the Primary DNS and this worked for me.

Hope this helps someone passing by.

answered Jan 2, 2021 at 18:09

Andrew Titus's user avatar

I enabled Trust Server Certificate in the Connection Properties and it worked for me

connection properties

answered Jan 19, 2021 at 13:30

Jahuso's user avatar

1

You might find out that you have more than one connection string, and you forgot to change the other one to Integrated Security to false. It happened to me. This answer might help someone.

I was focusing on the web config and the access rights, after a long hustle i remembered that I have another connection string in one of my classes for the emails, I had to change the connection string on the class to use the web config one.

answered Jan 21, 2022 at 10:21

Pidoski's user avatar

1

In .net Core also you may get this error if Trusted_Connection=True;
Is set. Sample setting in appsettings.json

ConnectionStrings": {
"DefaultConnection": "Server=serverName; Database=DbName; uid=userId; pwd=password; MultipleActiveResultSets=true"

},

Demodave's user avatar

Demodave

6,2526 gold badges44 silver badges60 bronze badges

answered Nov 11, 2020 at 5:47

Sam Patirage's user avatar

Sometime SSMS hang and close all of sudden ,then you get below error when you reconnect to SSMS

i) The Login is From an Untrusted Domain and Cannot be Used with Windows Authentication

OR

ii) The target principal name is incorrect .Cannot generate SSPI context.

In both cases RESTART YOUR MACHINE.

answered May 30, 2022 at 5:29

KumarHarsh's user avatar

KumarHarshKumarHarsh

5,0461 gold badge18 silver badges22 bronze badges

I also had a similar error but then I realised I just had changed the password for my system which caused this error.

To resolve it , I simply logged out of the current session and logged in again and this time

answered Aug 22, 2022 at 11:36

OrcaZep's user avatar

Please Use This Connection URL It’s Work Fine
«Data Source=Your IP Address;Initial Catalog = DatabaseName;User ID =sa;Password =your PassWord;TrustServerCertificate=True»

Example : «Data Source=192.168.150.122;Initial Catalog=StudentDb;User ID=sa; PassWord=123;TrustServerCertificate=True»

answered Dec 22, 2022 at 6:20

pradeep's user avatar

1

add TrustServerCertificate=»true»

similar option in MSSMS

also in command line run

ipconfig /flushdns
klist purge

answered Apr 13 at 7:57

Fantastory's user avatar

FantastoryFantastory

1,90621 silver badges25 bronze badges

If you have two servers on the same domain (eg. APP and DB), you can also use Windows Authentication between the app and MSSQL by setting up local users on both machines that match (same username and password). If you don’t have the passwords matched up, it can throw this error.

answered May 20, 2020 at 11:33

David Borough's user avatar

Following was working for me. hope this helps you

<add name="getconn" connectionString="Data Source=servername;Initial Catalog=DBName;Persist Security Info=True;User ID=sa;Password=***" />

Eric Aya's user avatar

Eric Aya

69.6k35 gold badges181 silver badges253 bronze badges

answered Dec 28, 2018 at 15:39

Hiren Patel's user avatar

Hiren PatelHiren Patel

3174 silver badges7 bronze badges

1

  • Remove From My Forums
  • Вопрос

  • Windows 8 Pro подключается к SQL Server 2008 R2/2012 по Windows Autentification. Если сидеть под локальной учётной записью, то подключается нормально и можно работать. Не нормально начинается когда подключаюсь под учётной записью Microsoft
    (ну эта, которая с минсвипером, пасьянсами и бесплатной почтой). Credential Manager настроить пробовал не помогло.

    Что делать?

    • Перемещено

      14 марта 2013 г. 14:46
      .

Ответы

  • Все просто — вы НЕ будете подключаться к SQL Server под Windows Autentification из под LiveID-учетки (она же имеется в виду?).

    Never. Impossible.

    Варианты. Их 2:

    1. Отставить баловство c I-net учетками и юзать «старые-добрые» local/domain учетки. И коннектиться к серверу под Windows
    Autentification.

    2. Продолжать баловаться с этими учетками, а SQL Server перевести в mixed-режим аутентификации.
    И конектиться, ясное дело, по логину/паролю.

    «Третьего не дано». (C)


    www.sqlCMD.ru — all around MS SQL Server

    • Предложено в качестве ответа
      Иван ПродановMicrosoft contingent staff, Moderator
      15 марта 2013 г. 23:39
    • Изменено
      Smarty
      18 марта 2013 г. 16:10
    • Помечено в качестве ответа
      Иван ПродановMicrosoft contingent staff, Moderator
      3 апреля 2013 г. 6:22

I am trying to host a SQL server database, but whenever I try to connect to it I get this error:

The login is from an untrusted domain and cannot be used with Windows
authentication

I am connecting through Matlab using the following command:

conn = database('Clinical_Data','DoyleLab07\Acc','','com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://DOYLELAB07\SQLEXPRESS:54287;database=Clinical_Data;integratedSecurity=true;').

Connecting to the database using matlab worked fine as long as I was using matlab on the computer which I was using to host the server. However, when I use another computer and the same Matlab command I get the error I showed above.

When I look under control panel\system. I notice that no domain is listed on my host PC or the PC I am using to connect to the host, but both computers are in the same workgroup. Would I be able to fix my problem by creating a domain and adding the foreign PC and the host to that domain? If so, how can this be accomplished?

Any suggestions will be very much appreciated.
Thank you for reading my post.

NotMe's user avatar

NotMe

87.4k27 gold badges171 silver badges245 bronze badges

asked Sep 4, 2013 at 0:46

Gaven's user avatar

2

Getting rid of Integrated Security=true worked for me.

JasonMArcher's user avatar

JasonMArcher

14.3k22 gold badges56 silver badges52 bronze badges

answered Aug 27, 2014 at 18:02

Shahid Miah's user avatar

Shahid MiahShahid Miah

5934 silver badges2 bronze badges

4

In order to use Windows Authentication one of two things needs to be true:

  1. You are executing from the same machine as the database server.
  2. You have an Active Directory environment and the user the application is executing under (usually the logged in user) has rights to connect to that database.

If neither of those are true you have to do one of two things:

  1. Establish a Windows Domain Controller, connect all of the relevant machines to that controller, then fix SQL server to use domain accounts; OR,
  2. Change SQL server to use both Windows and SQL Server accounts.

By FAR the easiest way is to change SQL Server to use both Windows and SQL server accounts. Then you just need to create a sql server user on the DB server and change your connection string to do that.

Best case option 1 will take a full day of installation and configuration. Option 2 ought to take about 5 minutes.

answered Sep 4, 2013 at 1:40

NotMe's user avatar

NotMeNotMe

87.4k27 gold badges171 silver badges245 bronze badges

4

If your SQL Server is on one domain controller and you are trying to connect to it from another domain controller then you will get this error when

IntegratedSecurity = true;

This will happen even if you include a valid SQL Server username and password in your connection string as they will automatically be over-written with your windows login and password. Integrated security means simply — use your windows credentials for login verification to SQL Server. So, if you are logged in to a different domain controller then it will fail. In the case where you are on two different domain controllers then you have no choice but to use

IntegratedSecurity = false;

Now, when Integrated security is false SQL Server will use the SQL Server login and password provided in your connection string. For this to work, the SQL Server instance has to have its authentication mode configured to mixed mode, being, SQL Server and Windows Authentication mode.

To verify or change this setting in SQL Server you can open the SQL Server Management Studio and right-click on your server name and then select Properties. On the pop-up that appears select Security and you will see where to alter this setting if you need to.

answered Jul 28, 2016 at 19:10

Jay's user avatar

JayJay

5485 silver badges11 bronze badges

2

I’ve had this same issue when using DNS aliases and hosts files to connect to a machine using a different domain name.

Say you have a SQL server called sql1 on mydomain.com — which is an Active Directory domain — and you also have a DNS zone for mydomain.net, and — for consistency — you set up a DNS alias (CNAME) record for database.mydomain.net --> sql1.mydomain.com

You’ll be able to connect to sql1.mydomain.com using Windows integrated security, but won’t be able to connect to database.mydomain.net even though it’s the same server because the domain name doesn’t match your AD domain.

answered May 27, 2015 at 19:51

Dylan Beattie's user avatar

Dylan BeattieDylan Beattie

53.7k35 gold badges130 silver badges197 bronze badges

1

This error message can also occur if the account you are using to access the SQL server is locked out by the domain.

answered Apr 6, 2015 at 16:58

GWLlosa's user avatar

GWLlosaGWLlosa

24k18 gold badges80 silver badges116 bronze badges

2

As mentioned here, you might need to disable the loopback

Loopback check can be removed by adding a registry entry as follows:

  • Edit the registry using regedit. (Start –> Run > Regedit )
  • Navigate to: HKLM\System\CurrentControlSet\Control\LSA
  • Add a DWORD value called “DisableLoopbackCheck” Set this value to 1

answered Feb 13, 2019 at 15:48

Miguel Febres's user avatar

Miguel FebresMiguel Febres

2,1532 gold badges22 silver badges31 bronze badges

If you using windows authentication make sure that password of the user hasn’t expired. An expired password can explain this error. This was the problem in my case.

answered Apr 9, 2019 at 9:19

S3minaki's user avatar

S3minakiS3minaki

2973 silver badges19 bronze badges

Why not use a SQL Server account and pass both the user name and password?

Here is the reason why.

In short, it looks like you have an authentication issue.

The problem with workgroups is there is no common Access Control List like Active Directory (AD). If you are using ODBC or JDBC, the wrong credentials are passed.

Even if you create a local windows account (LWA) on the machine (SE) that has SQL Express installed (SE\LWA), the credentials that will be passed from your client machine (CM) will be CM\LWA.

Richard Marskell - Drackir's user avatar

answered Sep 4, 2013 at 1:17

CRAFTY DBA's user avatar

CRAFTY DBACRAFTY DBA

14.4k4 gold badges26 silver badges30 bronze badges

Same Error with Connection String in Visual Studio dev environment

Our development database server was recently given a self-signed certificate so it automatically became untrusted. This resulted in the login error cited above. I added TrustServerCertificate=True to my connection string and it works now.

"Server=TheServerAddress; Database=TheDataBase; User Id=TheUsername; Password=ThePassword; TrustServerCertificate=True"

NOTE: This certificate configuration is not recommended for production environments.

answered Feb 22, 2022 at 22:46

Tyson Gibby's user avatar

Tyson GibbyTyson Gibby

2,7302 gold badges19 silver badges37 bronze badges

i removed Integrated Security=true and Trusted_Connection=True both of them , worked for me..

answered Feb 15, 2022 at 9:07

Rasool Aghajani's user avatar

In my case the Aliases within SQL Native Client 11.0 Configuration were pointing to invalid server/IP. Once updated it worked correctly.

To check:
1. Start «SQL Server Configuration Manager»
2. Navigate to «SQL Native Client 11.0 Configuration» and then «Aliases»
3. Ensure «Alias Name» and «Server» match correctly for TCP/IP

Ahmad's user avatar

Ahmad

5,5718 gold badges41 silver badges57 bronze badges

answered Oct 18, 2016 at 12:24

user4109297's user avatar

Following worked for me to get access from another machine to SQL Server using Windows Authentication. This approach may be useful only in development/test environment. E.g. you need to update password manually once you change it on your working machine.

On machine with SQL Server go to Control Panel and add new Windows User with same username and password as is on your working machine. Then create SQL Server login for this user:

CREATE LOGIN [SQLSERVERHOST\myuser] FROM WINDOWS;

Now you can use this login for Windows Authentication.

If you receive error ‘The login is from an untrusted domain’, this may mean that you changed password on your working machine and now need to update password on SQL Server machine.

answered Nov 30, 2018 at 9:51

ganisimov's user avatar

Just adding my suggestion for a resolution, I had a copy of a VM server for developing and testing, I created the database on that with ‘sa’ having ownership on the db.

I then restored the database onto the live VM server but I was getting the same error mentioned even though the data was still returning correctly. I looked up the ‘sa’ user mappings and could see it wasn’t mapped to the database when I tried to apply the mapping I got a another error «Fix: Cannot use the special principal ‘sa’. Microsoft SQL Server, Error: 15405». so I ran this instead

ALTER AUTHORIZATION ON DATABASE::dbname TO sa

I rechecked the user mappings and it was now assigned to my db and it fixed a lot of access issues for me.

answered Mar 4, 2019 at 15:22

Barry's user avatar

BarryBarry

213 bronze badges

Joining a WORKGROUP then rejoining the domain fixed this issue for me.

I got this error while using Virtual Box VM’s. The issue started to happen when I moved the VM files to a new drive location or computer.

Hope this helps the VM folks.

answered Feb 25, 2021 at 15:52

Andrew Titus's user avatar

We now use a privileged account management solution that changes our passwords regularly. I ended up receiving this error after my password was changed. Closing and re-opening SSMS with the new password resolved my issue.

answered May 31, 2019 at 13:34

Sam Bryant's user avatar

I started to get this error when i tried to login to SSMS using ‘windows Authentication’. This started to happen after i renamed the Windows SQL server. I tried everything to resolve this error and in my particular case changing the machine names in the ‘hosts’ file to reflect the name SQL server name change resolved the issue. C:\Windows\System32\Drivers\etc\hosts

answered Jun 19, 2019 at 11:28

KASTEER's user avatar

I had this problem because we where using a DNS name from an old server, ponting to a new server. Using the newserver\inst1 address, worked. both newserver\inst1 and oldserver\inst1 pointed to the same IP.

answered Jul 16, 2019 at 11:48

Luis Assuncao's user avatar

Yet another thing to check:

We had our nightly QA restore job stop working all of a sudden after another developer remoted into the QA server and tried to start the restore job during the middle of the day, which subsequently failed with the «untrusted domain» message. Somehow the server pointed to be the job’s maintenance plan was (changed?) using the ip address, instead of the local machine’s name. Upon replacing with the machine name the issue was resolved.

answered Sep 23, 2019 at 14:24

RIanGillis's user avatar

RIanGillisRIanGillis

6191 gold badge6 silver badges15 bronze badges

TLDR: Changing the DNS server to the loop back address worked for me.

I am working in VirtualBox and had setup two Windows Server 2016 instances. Server A is configure as a Domain Controller and Server B as an SQL Server. After adding Server B to the domain I cold not connect to with Management Studio from Server A. I was getting the «The login is from an untrusted domain and cannot be used with Windows authentication».

My initial configuration had the server getting its IP from the VirtualBox DHCP server.

I changed this to use static IP and entered the 127.0.0.1 address in the Primary DNS and this worked for me.

Hope this helps someone passing by.

answered Jan 2, 2021 at 18:09

Andrew Titus's user avatar

I enabled Trust Server Certificate in the Connection Properties and it worked for me

connection properties

answered Jan 19, 2021 at 13:30

Jahuso's user avatar

1

You might find out that you have more than one connection string, and you forgot to change the other one to Integrated Security to false. It happened to me. This answer might help someone.

I was focusing on the web config and the access rights, after a long hustle i remembered that I have another connection string in one of my classes for the emails, I had to change the connection string on the class to use the web config one.

answered Jan 21, 2022 at 10:21

Pidoski's user avatar

1

In .net Core also you may get this error if Trusted_Connection=True;
Is set. Sample setting in appsettings.json

ConnectionStrings": {
"DefaultConnection": "Server=serverName; Database=DbName; uid=userId; pwd=password; MultipleActiveResultSets=true"

},

Demodave's user avatar

Demodave

6,2526 gold badges44 silver badges60 bronze badges

answered Nov 11, 2020 at 5:47

Sam Patirage's user avatar

Sometime SSMS hang and close all of sudden ,then you get below error when you reconnect to SSMS

i) The Login is From an Untrusted Domain and Cannot be Used with Windows Authentication

OR

ii) The target principal name is incorrect .Cannot generate SSPI context.

In both cases RESTART YOUR MACHINE.

answered May 30, 2022 at 5:29

KumarHarsh's user avatar

KumarHarshKumarHarsh

5,0461 gold badge18 silver badges22 bronze badges

I also had a similar error but then I realised I just had changed the password for my system which caused this error.

To resolve it , I simply logged out of the current session and logged in again and this time

answered Aug 22, 2022 at 11:36

OrcaZep's user avatar

Please Use This Connection URL It’s Work Fine
«Data Source=Your IP Address;Initial Catalog = DatabaseName;User ID =sa;Password =your PassWord;TrustServerCertificate=True»

Example : «Data Source=192.168.150.122;Initial Catalog=StudentDb;User ID=sa; PassWord=123;TrustServerCertificate=True»

answered Dec 22, 2022 at 6:20

pradeep's user avatar

1

add TrustServerCertificate=»true»

similar option in MSSMS

also in command line run

ipconfig /flushdns
klist purge

answered Apr 13 at 7:57

Fantastory's user avatar

FantastoryFantastory

1,90621 silver badges25 bronze badges

If you have two servers on the same domain (eg. APP and DB), you can also use Windows Authentication between the app and MSSQL by setting up local users on both machines that match (same username and password). If you don’t have the passwords matched up, it can throw this error.

answered May 20, 2020 at 11:33

David Borough's user avatar

Following was working for me. hope this helps you

<add name="getconn" connectionString="Data Source=servername;Initial Catalog=DBName;Persist Security Info=True;User ID=sa;Password=***" />

Eric Aya's user avatar

Eric Aya

69.6k35 gold badges181 silver badges253 bronze badges

answered Dec 28, 2018 at 15:39

Hiren Patel's user avatar

Hiren PatelHiren Patel

3174 silver badges7 bronze badges

1

  • Remove From My Forums
  • Question

  • Error:

    ________

    Microsoft SQL Server Native Client Version 10.50.1600

    Running connectivity tests…

    Attempting connection
    [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

    TESTS FAILED!

    ______

    -I have a Domain user name

    —PC1 member of domain

    —PC2 not a member of domain

    I dont have access to SQL Server 2008.

    I receive the above error on PC2.  Is there a workaround for PC2?

    • Edited by

      Monday, October 10, 2016 6:16 PM

Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below:

Error: 18452, Severity: 14, State: 1.
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

You can see the screenshot of the error 18452 in below image.

error 18452

Error 18452 – Root Cause

Reason behind error 18452 is because of wrong security authentication mode configuration. SQL Server is set to accept only windows logins to connect to database instance.

As we know SQL Server uses two authentication modes to accept database connections. One is Windows Authentication mode and another one is SQL Server and Windows Authentication mode. We also call it Mixed Authentication mode.

Sometimes, SQL Server authentication mode is set to SQL Server and Windows Authentication mode to accept SQL as well as windows connections but still you will face this issue. That might be because you try to connect to a server that has Always on Availability Group configuration or database mirroring configuration.

Suppose you have AOAG configuration and you are connecting to database using primary replica name not listener name using a login for which default database is set as availability database. If failover got happen during your activity or you are connecting to secondary replica using a login for which default database is set as availability database then also you will get this error 18452 along with some SSPI context error that I have given below.

Error: 17806, Severity: 20, State: 14.
SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The Windows error code indicates the cause of failure. The logon attempt failed 

SSPI handshake errors comes because of Kerberos failure, which would most likely be related to non-existent SPN or bad SPN for SQL Server.

Solution

To fix this issue first we need to check the authentication mode set for your SQL Server Instance. If your SQL Server instance is running with windows authentication mode then you must change it to Mixed mode so that windows and SQL both type of logins can be authenticated.

To check the configured authentication mode for your SQL Server Instance, we need to launch SQL Server Instance property window. Right click at the instance node and click at the properties option as shown in below screenshot.

Launch SQL Server Instance Property Window

Once you will click at Properties option, you will be getting below SQL Server instance property window. Click at Security option from left side pane. You can see current Server Authentication configuration is set to Windows Authentication mode in below screenshot.

SQL Server Instance Property Window

Now we will change it to SQL Server and Windows Authentication mode. Select the radio button for SQL Server and Windows Authentication mode option and click ok button to proceed. You can see that I have selected above mode to apply the changes.

SQL Server Instance Property Window

Restart SQL Server services to apply the changes.

If your SQL Server Instance is already set with SQL Server and Windows Authentication mode then you should fix this issue in separate way. As I described above that one of the probable reason to get this error 18452 is because you might use AOAG replica server name to connect to the database with the login for which default database is set as the AOAG availability database.

If failover will happen then you would not be able to access the database because it will become secondary. Error 18452 will be generated along with SSPI handshake errors because same database is set as default database for your login that has become inaccessible now because of acting secondary database in AOAG. Failover will not happen for you because you are using replica server name to make database connection.

Possible solution to fix this issue is failback the AOAG to your earlier primary replica or you should use AOAG Listener name to make database connection. Also, to avoid this error during failover you should set default database for your login to master rather than availability database.

I hope you like this article. Please follow our Facebook page and Twitter handle to get latest updates.

Read More:

  • Fix Error 18456: Login failed for user “User_Name”
  • Fix Error 4064: Cannot open user default database. Login failed
  • Error 53: Could not open a connection on SQL Server
  • AOAG Listener Error 19471: The handle is Invalid
  • Author
  • Recent Posts

Manvendra Deo Singh

I am working as a Technical Architect in one of the top IT consulting firm. I have expertise on all versions of SQL Server since SQL Server 2000. I have lead multiple SQL Server projects like consolidation, upgrades, migrations, HA & DR. I love to share my knowledge. You can contact me on my social accounts for any consulting work.

Manvendra Deo Singh

Summary

Article Name

Fix Error 18452: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

Description

Recently we got a login issue where one of the SQL user was not able to connect to database instance and was getting error 18452. Full error description of this error is given below: Error: 18452, Severity: 14, State: 1.
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

  • The lord of the rings the battle for middle earth не запускается на windows 10
  • The lord of the rings the battle for middle earth как запустить на windows 10
  • The lord of the rings the battle for middle earth запуск на windows 10
  • The longest journey windows 10
  • The legend of zelda windows