My client application/browser authenticates against my server using Kerberos. The server runs Apache/Tomcat, and it talks to my service which runs on the server. My service can distribute work to another service on a different machine, so we will need to set up constrained delegation. My service on the server (on the server machine or the other machine) needs to talk to a SQL Server database using ODBC. I want to impersonate the end user (in AD). From reading online, to impersonate the end user, it seems like all I need to do is to make the SQLDriverConnect call to the ODBC driver on a thread which impersonates the end user.
If the user is already authenticated and I can get some token (TGT?) in my service, what API would I need to call in my service thread to impersonate the end user? I see ImpersonateLoggedOnUser and ImpersonateSecurityContext as likely options, but I don't really know which ones applies in my case and what specifically ticket/token I need here.
Also, I see that SetThreadToken can be an option too when the user is already authenticated. Is it?
My service is in C++ and the environment is Windows (7 or Server).