且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

登录失败.登录名来自不受信任的域,不能与 Windows 身份验证一起使用

更新时间:2021-09-03 08:57:10

您的连接字符串告诉它使用集成安全 SSPI,它将使用 Windows 凭据.

Your connection string is telling it to use integrated security SSPI, which will use the Windows credentials.

如果您要提供用户名和密码,请将 Integrated Security 设置为 false.

Set Integrated Security to false if you are going to be providing the username and password.

另外,考虑将您的连接字符串放在 web.config 文件中 - 它更安全且可重用.

Also, consider putting your connection string inside of the web.config file - it is more secure and reusable.

来自 http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=VS.100).aspx:

如果为 false,则在连接中指定用户 ID 和密码.如果为 true,则使用当前的 Windows 帐户凭据进行身份验证.识别值为true、false、yes、no、sspi(强烈推荐),相当于true.如果指定了用户 ID 和密码并且集成安全设置为 true,则用户 ID 和密码将被忽略并使用集成安全.