如何解决Azure“此版本的SQL Server不支持Windows登录”?

问题描述 投票:0回答:7

当我尝试连接到 SQL Azure 时,收到以下错误消息。

此版本的 SQL Server 不支持 Windows 登录

我正在使用 Azure 连接字符串。在开发过程中,我正在运行 SQL Server Express。当我尝试从数据库中获取一些数据时,会引发此特定错误。

我正在使用的上下文在 using 子句中运行,请参见下文

function List<SomeType> GetList(string dbContextName) 
{ 
    using (MyDbContext context = new MyDbContext) 
    {
         return context.SomeTypes.ToList();
    } 
}

我们使用实体框架版本 4.2、ASP.NET MVC 3 和 .NET 4.0。

如何解决这个问题?

c# sql-server asp.net-mvc entity-framework azure-sql-database
7个回答
55
投票

我正在使用用户/密码,但仍然收到错误消息。但是,我将其添加到我的连接字符串中并且它起作用了。

Trusted_Connection=False;Encrypt=True;

21
投票

设置

Integrated Security=False

在连接字符串中。


8
投票

您可能使用了不正确的连接字符串,这是适用于我的案例的连接字符串格式:

“ConnectionString”:“服务器=tcp:xxxx.database.windows.net,1433;数据库=xxx;用户ID=xxx;密码=xxx;加密=True;TrustServerCertificate=False;连接超时=30;”


7
投票

SQL Azure 不支持集成身份验证(即连接字符串中的 SSPI)。 仅支持 SQL 身份验证(即连接字符串中的用户名和密码)


7
投票

正如其他人已经提到的,SQL Azure 中仅支持 SQL Server 身份验证。 您可以阅读有关SQL Azure 的指南和限制 的更多信息。以及SQL Azure 的安全准则和限制

您必须在 MASTER 数据库中自行CREATE LOGIN,然后您需要在自定义 Azure 数据库中CREATE USER。另外不要忘记执行 sys.sp_addrolemember 向您的用户授予一些权限。

有关 在 SQL Azure 中管理用户和登录的更多信息可以在此处找到。

最后,您始终可以查看连接字符串的宝贵资源。


5
投票
1.**Windows Authentication** is not supported in Azure so you should go with **SQL Server Authentication**.
2.When you use SQL server Authentication you should pass User Id(Login in SQL server) and Password(Password in SQL server).
3.User Id should contain space in between should not be like UserId.
4.Trusted_Connection should be false.
The connection string in *appsettings.json* look like this:

"ConnectionStrings": {
    "DBContext": "Server=ServerName;Database=DbName;User Id=loginName;Password=loginPassword;Trusted_Connection=false;MultipleActiveResultSets=true"
  }

0
投票

如果您发现这个问题是因为您正在使用 SSMS 并收到此错误 即使 100% 没有选择 Windows 身份验证,那么我可以向您保证您不会失去理智。

在新的 Windows + SSMS 安装上,我刚刚尝试通过以下方式连接:

File > Connect Object Explorer

我收到有关不支持 Windows 身份验证的错误消息(我什至没有使用域)。尝试了三次(选择了 SQL Server 身份验证)后,我切换到使用

登录
Object Explorer > Connect > Database Engine

第一次就成功了。

© www.soinside.com 2019 - 2024. All rights reserved.