Sometimes you want to do double-hop querying in SQL Server, for example if you add a linked server connection ot your server and you want to query objects on that server from your client. Now, if you run integrated security (native mode) and you want your credentials to validate you from the client over the server and to the linked server, you will have to enable Kerberos.
I think that many have had problems with this (as I frequently see special accounts set up in the linked server definition). Here I put together a short recipe for those of you to try at home (or at work).
Step 1: Active Directory settings (http://support.microsoft.com/kb/917409):
- All accounts (users and computers) must belong to the same directory/forest.
- The user account must NOT be specified as a sensitive account (not for delegation).
- The user account must be specified as ”trusted for delegation”.
- Also, all involved computers must be ”trusted for delegation”.
Step 2: Run cmd command ”setspn” (assuming you are running the listener on the standard port 1433) (The following may look like the same lines repeated, but trust me, you need all of them!!)
- SETSPN -A MSSQLSvc/<NetBIOS servername> <sql service account>
- SETSPN -A MSSQLSvc/<NetBIOS servername>:1433 <sql service account>
- SETSPN -A MSSQLSvc/<FQDN servername> <sql service account>
- SETSPN -A MSSQLSvc/<FQDN servername>:1433 <sql service account>
In my home network NYDOMAIN where my sql server is named NYSTROMSQL.nydomain.local and the sql service account is NYDOMAINsqlservice the commands would thus be as follows: (run in CMD shell)
- SETSPN -A MSSQLSvc/NYSTROMSQL NYDOMAINsqlservice
- SETSPN -A MSSQLSvc/NYSTROMSQL:1433 NYDOMAINsqlservice
- SETSPN -A MSSQLSvc/NYSTROMSQL.nydomain.local NYDOMAINsqlservice
- SETSPN -A MSSQLSvc/NYSTROMSQL.nydomain.local:1433 NYDOMAINsqlservice
So now you´re done! Everything is working…or is it?
Well, you can easily verify that Kerberos validation is active by executing the following query:
select auth_scheme from sys.dm_exec_connections where session_id=@@spid
- ”KERBEROS” <= YES, you´re all set!
- ”NTLM” <= NO, it´s still not working.
I will return next week with what to do if you receive ”NTLM”, good luck!