programing

대상 주체 이름이 올바르지 않습니다.

goodcopy 2021. 1. 18. 22:06
반응형

대상 주체 이름이 올바르지 않습니다. SSPI 컨텍스트를 생성 할 수 없습니다.


컴퓨터 A에서 SQL Server를 실행하는 컴퓨터 B로 SQL Server 연결을 얻는 데 어려움을 겪고 있습니다.

나는 광범위하게 Google을 검색했지만 내가 찾은 모든 것이 작동하지 않았습니다. 또한이 문제를 해결하는 과정을 단계별로 안내하지도 않습니다.

Kerberos를 사용하지 않고 구성된 NTLM을 사용합니다.

여기에 이미지 설명 입력

관련된 머신은 다음과 같습니다 (xx는 보안을 위해 일부 머신 이름을 가리는 데 사용됨).

  • xxPRODSVR001 -Windows Server 2012 도메인 컨트롤러
  • xxDEVSVR003 -Windows Server 2012 (이 시스템에서 오류가 발생 함)
  • xxDEVSVR002 -Windows Server 2012 (이 컴퓨터는 SQL Server 2012를 실행 중입니다)

다음 SPN은 DC (xxPRODSVR001)에 등록되어 있습니다. 보안을 위해 yyy로 도메인을가 렸습니다.

CN = xxDEVSVR002, CN = Computers, DC = yyy, DC = local에 대해 등록 된 ServicePrincipalName :

            MSSQLSvc/xxDEVSVR002.yyy.local:49298

            MSSQLSvc/xxDEVSVR002.yyy.local:TFS

            RestrictedKrbHost/xxDEVSVR002

            RestrictedKrbHost/xxDEVSVR002.yyy.local

            Hyper-V Replica Service/xxDEVSVR002

            Hyper-V Replica Service/xxDEVSVR002.yyy.local

            Microsoft Virtual System Migration Service/xxDEVSVR002

            Microsoft Virtual System Migration Service/xxDEVSVR002.yyy.local

            Microsoft Virtual Console Service/xxDEVSVR002

            Microsoft Virtual Console Service/xxDEVSVR002.yyy.local

            SMTPSVC/xxDEVSVR002

            SMTPSVC/xxDEVSVR002.yyy.local

            WSMAN/xxDEVSVR002

            WSMAN/xxDEVSVR002.yyy.local

            Dfsr-12F9A27C-BF97-4787-9364-D31B6C55EB04/xxDEVSVR002.yyy.local

            TERMSRV/xxDEVSVR002

            TERMSRV/xxDEVSVR002.yyy.local

            HOST/xxDEVSVR002

            HOST/xxDEVSVR002.yyy.local

CN = xxDEVSVR003, CN = Computers, DC = yyy, DC = local에 대해 등록 된 ServicePrincipalName :

            MSSQLSvc/xxDEVSVR003.yyy.local:1433

            MSSQLSvc/xxDEVSVR003.yyy.local

            Hyper-V Replica Service/xxDEVSVR003

            Hyper-V Replica Service/xxDEVSVR003.yyy.local

            Microsoft Virtual System Migration Service/xxDEVSVR003

            Microsoft Virtual System Migration Service/xxDEVSVR003.yyy.local

            Microsoft Virtual Console Service/xxDEVSVR003

            Microsoft Virtual Console Service/xxDEVSVR003.yyy.local

            WSMAN/xxDEVSVR003

            WSMAN/xxDEVSVR003.yyy.local

            TERMSRV/xxDEVSVR003

            TERMSRV/xxDEVSVR003.yyy.local

            RestrictedKrbHost/xxDEVSVR003

            HOST/xxDEVSVR003

            RestrictedKrbHost/xxDEVSVR003.yyy.local

            HOST/xxDEVSVR003.yyy.local

이제 SQL Server 오류 메시지 만 더 설명적이고 연결하려는 주체 이름을 알려 주면이를 진단 할 수 있습니다.

그래서 누구든지이 문제를 해결하는 방법을 안내해 줄 수 있습니까? 아니면 제가 제공 한 것이 잘못된 것을 볼 수 있습니까?

더 많은 디버그 정보를 생성 해 드리겠습니다. 필요한 것을 알려주세요.


작업중인 ASP.NET MVC 앱에서이 문제가 발생했습니다.

최근에 비밀번호를 변경했음을 깨달았고 로그 아웃했다가 다시 로그인하여 수정할 수있었습니다.


나는 같은 문제로 약 몇 시간을 보냈다. 그것이 "Integrated Security=true"문제 일으킨 것으로 밝혀졌습니다 .

연결 문자열에서이 매개 변수를 제거하십시오.


Windows 인증을 사용하여 SQL Server Management Studio를 통해 연결할 때이 오류가 발생했습니다. 내 암호가 만료되었지만 아직 변경하지 않았습니다. 일단 변경되면 컴퓨터가 새 자격 증명을 사용하여 작동하도록 로그 아웃했다가 다시 로그인해야했습니다.


암호 대신 PIN을 사용하여 Windows 10에 로그인했습니다. 로그 아웃했다가 대신 내 암호로 다시 로그인했으며 Management Studio를 통해 SQL Server에 로그인 할 수있었습니다.


Windows 인증을 시도 할 때 동일한 오류가 발생했습니다. 우스꽝스럽게 들리지만 다른 사람에게 도움이되는 경우를 대비하여 : 로그인 (!)하는 동안 내 도메인 계정이 어떻게 든 잠 겼기 때문입니다. 계정을 잠금 해제하면 문제가 해결되었습니다.


이 가장 모호한 오류에 또 다른 잠재적 솔루션을 추가하려면 다음을 수행하십시오 The target principal name is incorrect. Cannot generate SSPI context. (.Net SqlClient Data Provider).

SQL Server를 ping 할 때 확인 된 IP가 구성 관리자의 IP와 동일한 지 확인합니다. 확인하려면 SQL Server 구성 관리자를 열고 SQL Server 네트워크 구성> MSSQLServer 용 프로토콜> TCP / IP로 이동합니다.

TCP / IP가 활성화되어 있는지 확인하고 IP 주소 탭에서 ping 할 때 서버가 확인하는 IP가 여기에서 동일한 지 확인합니다. 그것은 나를 위해이 오류를 수정했습니다.


SQL Box와 클라이언트 모두에 로그인하고 다음을 입력합니다.

ipconfig /flushdns
nbtstat -R

그래도 작동하지 않으면 클라이언트 컴퓨터에서 DHCP를 갱신하세요 ... 이것은 사무실에있는 2 대의 PC에서 작동합니다.


SSPI 컨텍스트 오류는 확실히 Kerberos를 사용하여 인증을 시도하고 있음을 나타냅니다.

kerberos를 사용하는 경우 보안 이벤트 로그를 확인하십시오. 인증 패키지 : Kerberos를 사용한 로그온 시도가 표시되어야합니다.

NTLM 인증이 실패 할 수 있으므로 kerberos 인증을 시도하고 있습니다. 보안 이벤트 로그에서 NTLM 로그온 시도 실패를 볼 수도 있습니까?

dev에서 kerberos 이벤트 로깅을 켜서 매우 장황하지만 kerberos가 실패하는 이유를 디버깅 할 수 있습니다.


나는 이것을 만났고 두 가지를 수행하여 수정했습니다.

  1. https://support.microsoft.com/en-us/kb/811889에 설명 된대로 ADSI 편집을 사용하여 서비스 계정에 읽기 / 쓰기 servicePrincipalName 권한 부여
  2. 다음을 사용하여 SQL Server 컴퓨터 계정 (서비스 계정과 반대) 에 이전에 존재했던 SPN 제거

    setspn -D MSSQLSvc/HOSTNAME.domain.name.com:1234 HOSTNAME
    

    여기서 1234 는 인스턴스에서 사용하는 포트 번호입니다 (마인은 기본 인스턴스가 아님).


제 경우에는 SQL Server 2014 (개발 서버에서)를 다시 시작하면 문제가 해결되었습니다.


격리 된 네트워크의 PC 클러스터에서 IPv6를 테스트하고 있었는데 IPv4로 되 돌렸을 때이 문제가 발생했습니다. 나는 활성 디렉토리, DNS 및 DHCP에서 놀았으므로 Kerberos 설정을 깨기 위해 무엇을 찌르는 지 알지 못했습니다.

내가 찾은 원격 연결을 연결하는 유용한 팁을 사용하여 소프트웨어 외부의 연결을 다시 테스트했습니다.

https://blogs.msdn.microsoft.com/steverac/2010/12/13/test-remote-sql-connectivity-easily/

그런 다음 간단한 검색을 통해 Microsoft 웹 사이트 https://support.microsoft.com/en-gb/help/811889/how-to-troubleshoot-the-cannot-generate-sspi-context-error-message 에서이를 발견했습니다 .

SQL 서버에서 도구를 실행하여 상태가 오류 인 경우 문제가 있는지 확인한 다음 나타나는 수정 버튼을 누르십시오.

이것은 나를 위해 문제를 해결했습니다.


웹 애플리케이션에 액세스 할 때이 문제가 발생했습니다. 최근에 Windows 암호를 변경했기 때문일 수 있습니다.

이 문제는 웹 응용 프로그램을 호스팅 한 앱 풀의 암호를 업데이트하면 해결되었습니다.


클라이언트와 서버 간의 시계 일치를 확인하십시오.

이 오류가 간헐적으로 발생했을 때 위의 답변 중 어느 것도 작동하지 않았으며 일부 서버에서 시간이 이동 한 것을 발견했습니다. 다시 동기화되면 오류가 사라졌습니다. Windows에서 시간을 자동으로 동기화하는 방법을 보려면 w32tm 또는 NTP를 검색하십시오.


내 문제에 대한 해결책을 찾을 때 여기에 도착했기 때문에 다른 사람들도 여기에 도착할 경우를 대비하여 여기에 내 해결책을 공유하겠습니다.

내 컴퓨터가 다른 도메인의 다른 사무실로 이동할 때까지 SQL Server에 제대로 연결했습니다 . 그런 다음 전환 후 대상 주체 이름과 관련 하여이 오류가 발생했습니다. 수정 된 것은 server.domain.com 과 같은 정규화 된 이름을 사용하여 연결하는 것 입니다. 그리고 실제로 첫 번째 서버에 그런 식으로 연결하면 서버 이름 만 사용하여 (전체 자격없이) 다른 서버에 연결할 수 있지만 마일리지는 다를 수 있습니다.


나는 오늘 이것을 만났고 내 수정 사항을 공유하고 싶었습니다. 이것은 단순히 간과되고 수정하기 쉽기 때문입니다.

우리는 자체 rDNS를 관리하고 최근에 서버 이름 지정 체계를 다시 수정했습니다. 그 일환으로 우리는 rDNS를 업데이트하고 이것을하는 것을 잊었습니다.

ping이 올바른 호스트 이름을 찾았지만 ping -a가 잘못된 호스트 이름을 반환했습니다.

Easy fix: change the rDNS, do an ipconfig /flushdns, wait 30 seconds (just something I do), do another ping -a , see it resolving the correct hostname, connect ... profit.


I ran into a new one for this: SQL 2012 hosted on Server 2012. Was tasked to create a cluster for SQL AlwaysOn.
Cluster was created everyone got the SSPI message.

To fix the problems ran following command:

setspn -D MSSQLSvc/SERVER_FQNName:1433 DomainNamerunningSQLService

DomainNamerunningSQLService == the domain account I set for SQL I needed a Domain Administrator to run the command. Only one server in the cluster had issues.

Then restarted SQL. To my surprise I was able to connect.


I was trying to connect to a VM running SQL Server 2015 from my laptop in a Visual Studio 2015 Console App. I run my app the night before and it is fine. In the morning I try to debug the app and I get this error. I tried ipconfig/flush and release + renew and a a bunch of other garbage, but in the end...

Restart your VM and restart the client. That fixed it for me. I should have known, restart works every time.


Make sure that "Named Pipes" are enabled from "SQL Server Configuration Manager". This worked for me.

  1. Open "SQL Server Configuration Manager".
  2. Expand "SQL Server Network Configuration", from the list on the left.
  3. Select "Protocols for [Your Instance Name]".
  4. Right click on "Named Pipes", from the list on the right.
  5. Select "Enable"
  6. Restart your Instance service.

I ran into a variant of this issue, here were the characteristics:

  • User was able to successfully connect to a named instance, for example, connections to Server\Instance were successful
  • User was unable to connect to the default instance, for example, connections to Server failed with the OP's screenshot regarding SSPI
  • User was unable to connect default instance with fully qualified name, for example, connections to Server.domain.com failed (timeout)
  • User was unable to connect IP address without named instance, for example, connections to 192.168.1.134 failed
  • Other users not on the domain (for example, users who VPN to the network) but using domain credentials were able to successfully connect to the default instance and IP address

So after many headaches of trying to figure out why this single user couldn't connect, here are the steps we took to fix the situation:

  1. Take a look at the server in the SPN list using
    setspn -l Server
    a. In our case, it said Server.domain.com
  2. Add an entry to the hosts file located in C:\Windows\System32\drivers\etc\hosts (run Notepad as Administrator to alter this file). The entry we added was
    Server.domain.com Server

After this, we were able to successfully connect via SSMS to the default instance.


I had this problem on my sql server. I setspn -D mssqlsvc\Hostname.domainname Hostname then stoped and started my SQL server service.

I am thinking that just stopping and starting my sql service would have done it.


I too had this problem on SQL Server 2014 while logging with windows Authentication, to resolve the issue i have Restarted my server once and then try to login, it worked for me.


I had the same issue, but locking, and unlocking the machine worked for me. Sometimes, firewall issues will give errors.

I am not sure it will work for you or not, just sharing my experience.


I had the same issue. I recently changed my windows password and my website was throwing the error. I tried to logout and login but not worked. Then I realized I configured my defaultappppol using my account in the "custom account" section and I configured the account once again using the new password. This did the magic!!! Please let me know your feedback on this solution.


I have tried all the solutions here and none of them have worked yet. A workaround that is working is to Click Connect, enter the server name, select Options, Connection Properties tab. Set the "Network protocol" to "Named Pipes". This allows users to remote connect using their network credentials. I'll post an update when I get a fix.


I'm running a Mickey Mouse testing system based on SQL.COM.

I ran setspn -T sql -F -Q */Servername (in this case SQL01) on both the machine I couldn't connect to and a machine I could. I then simply removed the additional entries in the problem machine and it all worked, e.g. setspn -D MSSQLSvc/SQL01.SQL.COM:1433 SQL01


Seems to be issue is related to DNS Server. To resolve this issue change the IP Address to ComputerName.

Example: Change the value "10.0.0.10\TestDB" to "YourcomputerName\TestDB"


Not at all an ideal solution, I just wanted to add this for future reference for anyone seeing this page:

I was having this issue trying to connect to a remote SQL Server instance using my domain account, trying the same thing on an instance hosted on a different machine worked fine.

So if you have the option to just use a different instance it may help, but this doesn't actually address whatever the issue is.


I'll add this here as it caught me out and may help someone else. Caveat emptor, I am not a windows person, but had to look at a scenario that included SQL server.

I downloaded the developer version of the full SQL Server product and installed it on Windows 10. All good for local connections, nothing for the remote client.

Tried many of the above but it eventually dawned on me that the Windows Authentication wanted to authenticate remoteclient\myuser and there was no way in a standalone Windows world to create a mechanism to authenticate against (As I understand it kerberos). The error message being "Cannot generate SSPI context".

Using SQL Authentication didn't appear to work either.

I eventually went back to SQL Server Express which has a combined mode and I could then use SQL Authentication from the remote clients.


In my case, the problem was setting up DNS on the wifi. I removed the settings, and left them empty, and worked.

DNS를 구성하는 Como ficou minha


하나의 SQL Server에서만이 오류가 발생한 사용자가 한 명뿐입니다. 그는 서버 이름에 대한 Windows 자격 증명 아래의 제어판-자격 증명 관리자에 이전 암호를 저장 한 것으로 나타났습니다. 저장된 자격 증명을 제거하고 작동했습니다.

참조 URL : https://stackoverflow.com/questions/32309922/the-target-principal-name-is-incorrect-cannot-generate-sspi-context

반응형