Trouble Connecting to sql server Login failed. "The login is from an untrusted domain and cannot be used with Windows authentication"

配置单个数据库的权限的话

Security里面找到login,右键看属性

找到UserMapping,找到对应的数据库,权限那边勾选db_user, db_reader和db_datawriter权限

 

 

Trouble Connecting to sql server Login failed. "The login is from an untrusted domain and cannot be used with Windows authentication"

回答1

Getting rid of Integrated Security=true worked for me.

 

回答2

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.

 

格式修改如下:

<connectionStrings>
<add name="DataAccess" providerName="System.Data.SqlClient" connectionString="database=Hotel;server=127.0.0.1,1433;UID=sa;PWD=123456;Current Language=English;Connection Timeout=120;" />
</connectionStrings>

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(523)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2017-09-04 invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
2017-09-04 学习JavaScript
2015-09-04 查找2个分支的共同父节点
点击右上角即可分享
微信分享提示