如何解决Azure“;在此版本的SQL Server中不支持Windows登录;

本文关键字:SQL Server 版本 登录 Windows 不支持 何解决 解决 Azure | 更新日期: 2023-09-27 18:28:42

当我尝试连接到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。

如何解决此问题?

如何解决Azure“;在此版本的SQL Server中不支持Windows登录;

我正在使用user/pass,但仍然收到错误消息。但是,我把它添加到我的连接字符串中,它就起作用了。

Trusted_Connection=False;Encrypt=True;

设置

Integrated Security=False

在连接字符串中。

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

"ConnectionString":"Server=tcp:xxxx.database.windows.net,1433;database=xxx;用户ID=xxx;密码=xxx;加密=True;TrustServerCertificate=False;连接超时=30;"

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

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

您必须在MASTER数据库中自己创建LOGIN,然后您将希望在自定义Azure数据库中创建USER。另外,不要忘记执行sys.sp_addrolemember来向用户授予一些权限。

有关在SQL Azure中管理用户和登录的详细信息,请访问此处。

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

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"
  }