SQL 无法创建 SSPI 上下文

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1812541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:35:03  来源:igfitidea点击:

Cannot create SSPI context

sqlsql-serversecuritysspi

提问by Prasanna

I am working on a .NET application where I am trying to build the database scripts. While building the project, I am getting an error "Cannot create SSPI context.". This error is shown in the output window (inside VS2008 screen) and the building process failed. Please help on this. SQL Server is configured to work on Windows authentication & running as network service (these two things are must for my project).

我正在尝试构建数据库脚本的 .NET 应用程序。在构建项目时,我收到错误“无法创建 SSPI 上下文。”。此错误显示在输出窗口中(在 VS2008 屏幕内)并且构建过程失败。请帮忙解决这个问题。SQL Server 被配置为在 Windows 身份验证上工作并作为网络服务运行(这两件事对于我的项目来说是必须的)。

Please help on this. This error is not seems to be consistent. It was fixed in the past by restarting the machine, changing the system time to match the domain time and some suggestions in the net. Please help on this.

请帮忙解决这个问题。这个错误似乎不一致。过去通过重新启动机器,更改系统时间以匹配域时间和网络中的一些建议来修复它。请帮忙解决这个问题。

采纳答案by gbn

It's quite a common error with a variety of causes: start here with KB 811889

这是一个很常见的错误,原因多种多样:从KB 811889开始

  • What version of SQL Server?
  • And Windows on client and server?
  • Local or network SQL instance?
  • Domain or workgroup? Provider?
  • Changing password
  • Local windows log errors?
  • Any other apps affected?
  • 什么版本的 SQL Server?
  • 客户端和服务器上的Windows?
  • 本地或网络 SQL 实例?
  • 域还是工作组?供应商?
  • 更改密码
  • 本地 Windows 日志错误?
  • 任何其他应用程序受到影响?

回答by Jeremy McGee

It sounds like your PC hasn't contacted an authenticating domain controller for a little while. (I used to have this happen on my laptop a few times.)

听起来您的 PC 已经有一段时间没有联系身份验证域控制器了。(我曾经在我的笔记本电脑上发生过几次这种情况。)

It can also happen if your password expires.

如果您的密码过期,也会发生这种情况。

回答by Erik Mandke

I had the same issue after changing the user which was running the MSSQLSERVER-Service

更改运行 MSSQLSERVER-Service 的用户后,我遇到了同样的问题

To solve incorrect SPNs with SQL Server I used this tool

为了使用 SQL Server 解决不正确的 SPN,我使用了这个工具

http://www.microsoft.com/en-us/download/details.aspx?id=39046- Microsoft? Kerberos Configuration Manager for SQL Server

http://www.microsoft.com/en-us/download/details.aspx?id=39046- 微软?SQL Server 的 Kerberos 配置管理器

In my case it worked pretty well.

就我而言,它工作得很好。

回答by Ritesh Gujaran

This error usually comes when the Windows user account is expired and he is already logged in with old password. Just ask the user to restart his machine and check if the password is expired or he has changed the password. Hope this helps!!!!!

当 Windows 用户帐户过期并且他已经使用旧密码登录时,通常会出现此错误。只需让用户重新启动他的机器并检查密码是否已过期或他是否更改了密码。希望这可以帮助!!!!!

回答by Mahesh

If you are hosting on IIS, make sure the password for the AppPool account has not changed.

如果您在 IIS 上托管,请确保 AppPool 帐户的密码未更改

If it has, then follow these steps:

如果有,请按照以下步骤操作:

  • Go to IIS
  • Click on Application Pools
  • Select the AppPool of your application
  • Right Click on your AppPool
  • Advanced settings
  • Identity
  • Update Password
  • Restart AppPool
  • 进入 IIS
  • 单击应用程序池
  • 选择您的应用程序的 AppPool
  • 右键单击您的 AppPool
  • 高级设置
  • 身份
  • 更新密码
  • 重启应用池

回答by Andrew

First thing you should do is go into the logs (Management\SQL Server Logs) and see if SQL Server successfully registered the Service Principal Name (SPN). If you see some sort of error (The SQL Server Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service) then you know where to start.

您应该做的第一件事是进入日志 ( Management\SQL Server Logs) 并查看 SQL Server successfully registered the Service Principal Name (SPN). 如果您看到某种错误 ( The SQL Server Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service),那么您就知道从哪里开始。

We saw this happen when we changed the account SQL Server was running under. Resetting it to Local System Account solved the problem. Microsoft also has a guideon manually configuring the SPN.

当我们更改运行 SQL Server 的帐户时,我们看到了这种情况。将其重置为本地系统帐户解决了问题。Microsoft 还提供有关手动配置 SPN的指南

回答by CuriousDiscer

I resolved my Cannot Generate SSPI Contexterror by using the SQL Server Configuration Manager. Since I have SQL Server native client 10.0 on my machine, the connection to the server is trying to use named pipes (or shared memory?). Other machines could run my app with no problem. When I looked at the configuration manager, named pipes and shared memory were both enabled (good). However, under alias, the name of the computer was there with TCP forced. Since I didn't know what effect changing this would have, I changed the connection string in my program to use <servername>.<domainname> instead. Fixed.

Cannot Generate SSPI Context使用 SQL Server 配置管理器解决了我的错误。由于我的机器上有 SQL Server 本机客户端 10.0,到服务器的连接正在尝试使用命名管道(或共享内存?)。其他机器可以毫无问题地运行我的应用程序。当我查看配置管理器时,命名管道和共享内存都已启用(很好)。但是,在别名下,计算机的名称是强制使用 TCP 的。由于我不知道更改此设置会产生什么影响,因此我将程序中的连接字符串更改为使用 <servername>.<domainname> 代替。固定的。

回答by Guilherme de Jesus Santos

I also issued this problem, and the server admins solved it by following the same solution as indu_teja proposed in http://www.sqlservercentral.com/Forums/Topic546566-146-1.aspx

我也发布了这个问题,服务器管理员按照与http://www.sqlservercentral.com/Forums/Topic546566-146-1.aspx 中提出的 indu_teja 相同的解决方案解决了它

The solution proposed by indu_teja says :

indu_teja 提出的解决方案说:

If you get this "SSPI Context Error". The issues we face are:

  1. We will not be able to connect to SQL Server remotely.
  2. However we will be able to connect to server with local account.

CAUSE: The issue might be becasue of no proper sync happenign fro the SPNs in Active directory.

RESOLUTION:

  1. You need to reset SPN. Use the synytax "SET SPN". You can check the syntax in net once.
  2. Change your sql server service account from domain account to Local account, recycle sql, and then reset again with your domain account and recycle sql server.

如果您收到此“SSPI 上下文错误”。我们面临的问题是:

  1. 我们将无法远程连接到 SQL Server。
  2. 但是,我们将能够使用本地帐户连接到服务器。

原因:该问题可能是因为 Active Directory 中的 SPN 没有正确同步。

解析度:

  1. 您需要重置 SPN。使用语法“SET SPN”。您可以在 net 中检查一次语法。
  2. 把你的sql server服务账户从域账户改成本地账户,回收sql,然后用你的域账户重新设置,回收sql server。

回答by Remus Rusanu

The "Cannot Generate SSPI Context" error is very generic and can happen for a multitude of reasons. Is just a cover error for any underlying Kerberos/NTLM error. Gbn's KB article link is a very good starting point and usualy solves the issues. If you still have problems I recommend following the troubleshooting steps in Troubleshooting Kerberos Errors.

“无法生成 SSPI 上下文”错误非常普遍,可能由于多种原因而发生。只是任何底层 Kerberos/NTLM 错误的掩护错误。Gbn 的 KB 文章链接是一个很好的起点,通常可以解决问题。如果您仍然有问题,我建议您按照故障排除 Kerberos 错误中的故障排除步骤进行操作。

回答by Mark Ngugi

I just had the same problem and all I did was delete the user log in credentials in sql server using another user id and adding them back.

我只是遇到了同样的问题,我所做的就是使用另一个用户 ID 删除 sql server 中的用户登录凭据并将其添加回来。