Article ID: 811889 - Last Review: August 11, 2009 - Revision: 21.0 How to troubleshoot the "Cannot generate SSPI context" error messageOn This PageSUMMARY This step-by-step article describes how to troubleshoot the
most typical sources of the "Cannot generate SSPI context" error message. You
may receive this error message under the following conditions:
Understanding Kerberos terminology and Service Principal NameThe SQL Server driver on a client computer uses integrated security to use the Windows security token of the user account to successfully connect to a computer that is running SQL Server. The Windows security token is delegated from the client to the computer that is running SQL Server. The SQL Server driver performs this delegation when the user's security token is delegated from one computer to another by using one of the following configurations:
The "Cannot generate SSPI context" error is generated when SSPI uses Kerberos to delegate over TCP/IP and Kerberos cannot complete the necessary operations to successfully delegate the user security token to the destination computer that is running SQL Server. Why Security Support Provider Interface chooses NTLM or KerberosKerberos uses an identifier named "Service Principal Name" (SPN). Consider an SPN as a domain or forest unique identifier of some instance in a network server resource. You can have an SPN for a Web service, for an SQL service, or for an SMTP service. You can also have multiple Web service instances on the same physical computer that has a unique SPN.An SPN for SQL Server is composed of the following elements:
When the SQL Server driver on a client uses integrated security to connect to SQL Server, the driver code on the client tries to resolve the fully qualified DNS of the computer that is running SQL Server by using the WinSock networking APIs. To perform this operation, the driver code calls the gethostbyname and gethostbyaddr WinSock APIs. Even if an IP address or host name is passed as the name of the computer that is running SQL Server, the SQL Server driver tries to resolve the fully qualified DNS of the computer if the computer is using integrated security. When the SQL Server driver on the client resolves the fully qualified DNS of the computer that is running SQL Server, the corresponding DNS is used to form the SPN for this computer. Therefore, any issues pertaining to how the IP address or host name is resolved to the fully qualified DNS by WinSock may cause the SQL Server driver to create an invalid SPN for the computer that is running SQL Server. For example, the invalid SPNs that the client-side SQL Server driver can form as resolved fully qualified DNS are:
The key factor that makes Kerberos authentication successful is the valid DNS functionality on the network. You can verify this functionality on the client and the server by using the Ping command-line utility. On the client computer, run the following command to obtain the IP address of the server that is running SQL Server (where the name of the computer that is running SQL Server is SQLServer1): ping sqlserver1 To see if the Ping command-line utility resolves the
fully qualified DNS of SQLServer1, run the following command:ping -a IPAddress For example: C:\>ping SQLSERVER1
Pinging SQLSERVER1 [123.123.123.123] with 32 bytes of data:
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Ping statistics for 123.123.123.123:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\>ping -a 123.123.123.123
Pinging SQLSERVER1.northamerica.corp.mycompany.com [123.123.123.123] with 32 bytes of data:
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Reply from 123.123.123.123: bytes=32 time<10ms TTL=128
Ping statistics for 123.123.123.123:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\>SQL Server Service Principal Name creationThis is one of the critical parts of Kerberos and SQL Server interaction. With SQL Server, you can run the SQL Server service under one of the following: a LocalSystem account, a local user account, or a domain user account. When the SQL Server service instance starts, it tries to register its own SPN in Active Directory by using the DsWriteAccountSpn API call. If the call is not successful, the following warning is logged in Event Viewer:Source: MSSQLServer EventID: 19011 Description: SuperSocket info: (SpnRegister) : Error 8344. For more information about the DsWriteAccountSpn function, visit the following Microsoft Web site:http://msdn2.microsoft.com/en-us/library/ms676056.aspx
(http://msdn2.microsoft.com/en-us/library/ms676056.aspx)
Simplified explanationIf you run the SQL Server service under the LocalSystem account, the SPN is automatically registered and Kerberos interacts successfully with the computer that is running SQL Server. However, if you run the SQL Server service under a domain account or under a local account, the attempt to create the SPN will fail in most cases because the domain account and the local account do not have the right to set their own SPNs. When the SPN creation is not successful, this means that no SPN is set up for the computer that is running SQL Server. If you test using a domain administrator account as the SQL Server service account, the SPN is successfully created because the domain administrator-level credentials that you must have to create an SPN are present.Because you might not use a domain administrator account to run the SQL Server service (to prevent security risk), the computer that is running SQL Server cannot create its own SPN. Therefore, you must manually create an SPN for your computer that is running SQL Server if you want to use Kerberos when you connect to a computer that is running SQL Server. This is true if you are running SQL Server under a domain user account or under a local user account. The SPN you create must be assigned to the service account of the SQL Server service on that particular computer. The SPN cannot be assigned to the computer container unless the computer that is running SQL Server starts with local system. There must be one and only one SPN, and it must be assigned to the appropriate container. Typically, this is the current SQL Server service account. However, this is the computer account with local system. Verify the domainVerify that the domain that you log on to can communicate with the domain to which the computer that is running SQL Server belongs. There must also be proper name resolution in the domain.
How to configure the SQL Server service to create SPNs dynamically for the SQL Server instancesTo configure the SQL Server service to create SPNs dynamically, you must modify the account's access control settings in the Active Directory directory service. You must grant the "Read servicePrincipalName" permission and the "Write servicePrincipalName" permission for the SQL Server service account.Warning If you use the Active Directory Service Interfaces (ADSI) Edit snap-in, the LDP utility, or any other LDAP version 3 clients and you incorrectly modify the attributes of Active Directory objects, you can cause serious problems. These problems may require that you reinstall Microsoft Windows Server 2003, Microsoft Windows 2000 Server, Microsoft Exchange Server 2003, Microsoft Exchange 2000 Server, or both Windows and Exchange. We cannot guarantee that problems caused by incorrectly modifying the attributes of Active Directory objects can be resolved. Modify these attributes at your own risk. Note To grant the appropriate permissions and user rights to the SQL Server startup account, you must be logged on as a domain administrator, or you must ask your domain administrator to do this task. To configure the SQL Server service to create SPNs dynamically, follow these steps:
Verify the server environmentCheck some basic settings on the computer where SQL Server is installed:
Verify the client environmentVerify the following on the client:
Verify the client network utilityThe Client Network Utility (CNU) is delivered together with Microsoft Data Access Components (MDAC) and it is used to configure connectivity to computers that are running SQL Server. You can use the MDAC Cliconfg.exe CNU utility to configure connectivity:
Information to collect to open a Microsoft Product Support (PSS) caseIf you cannot obtain the cause of the problem by using the troubleshooting steps in this article, collect the following information and open a Microsoft Product Support (PSS) case:For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site: http://support.microsoft.com/contactus/?ws=support
(http://support.microsoft.com/contactus/?ws=support)
How to manually set up a Service Principal Name for SQL ServerFor more information about how to manually set up a Service Principal Name for SQL Server, click the following article number to view the article in the Microsoft Knowledge Base:319723
(http://support.microsoft.com/kb/319723/
)
How to use Kerberos authentication in SQL Server
The Security Support Provider Interface (SSPI) is the interface
to Microsoft Windows NT security that is used for Kerberos authentication, and
supports the authentication scheme of the NTLM Security Support Provider.
Authentication occurs at the operating system level when you log on to a
Windows domain. Kerberos authentication is only available on Windows 2000-based
computers that have Kerberos enabled and that are using Active Directory.
SSPI is only used for TCP/IP connections that are made by using Windows Authentication. (Windows Authentication is also known as Trusted Connections or Integrated Security.) SSPI is not used by Named Pipes or multi-protocol connections. Therefore, you can avoid the problem by configuring your clients to connect from a protocol other than TCP/IP. When a SQL Server client tries to use integrated security over TCP/IP sockets to a remote computer that is running SQL Server, the SQL Server client network library uses the SSPI API to perform security delegation. The SQL Server network client (Dbnetlib.dll) makes a call to the AcquireCredentialsHandle function and passes in "negotiate" for the pszPackage parameter. This notifies the underlying security provider to perform negotiate delegation. In this context, negotiate means to try either Kerberos or NTLM authentication on Windows-based computers. In other words, Windows use Kerberos delegation if the destination computer that is running SQL Server has an associated, correctly configured SPN. Otherwise, Windows use NTLM delegation. Note Verify that you are not using an account named "SYSTEM" to start any of the SQL Server services (MSSQLServer, SQLServerAgent, MSSearch). The keyword SYSTEM may cause conflicts with the Key Distribution Center (KDC). REFERENCES For more information about how Kerberos and SSPI
security works, click the following article numbers to view the articles in the
Microsoft Knowledge Base: 266080
(http://support.microsoft.com/kb/266080/
)
Answers to frequently asked Kerberos questions
231789
(http://support.microsoft.com/kb/231789/
)
Local logon process for Windows 2000
304161
(http://support.microsoft.com/kb/304161/
)
SSPI mutual authentication is indicated on the client side but not on the server side
232179
(http://support.microsoft.com/kb/232179/
)
Kerberos administration in Windows 2000
230476
(http://support.microsoft.com/kb/230476/
)
Description of common Kerberos-related errors in Windows 2000
262177
(http://support.microsoft.com/kb/262177/
)
How to enable Kerberos event logging
277658
(http://support.microsoft.com/kb/277658/
)
Setspn fails if domain name differs from NetBIOS name where SQL Server SPN is registered
244474
(http://support.microsoft.com/kb/244474/
)
How to force Kerberos to use TCP instead of UDP in Windows Server 2003, in Windows XP, and in Windows 2000
326985
(http://support.microsoft.com/kb/326985/
)
How to troubleshoot Kerberos-related issues in IIS
To see a white paper about Microsoft SQL Server 2000
security, visit the following Microsoft Web site: http://technet.microsoft.com/en-us/cc984178.aspx
(http://technet.microsoft.com/en-us/cc984178.aspx)
APPLIES TO
| Article Translations
|
Back to the top
