I'm trying to call a web service using Impersonation. When I do the request with ImpersonationLevel set, I get a 401 Unauthorized exception thrown at GetResponse. When I do it without impersonation (thereby making the request using the server service account), I to get a response and no exceptions thrown.
My goal is to use Impersonation so that I can make the web service call using the client's credentials via kerberos. The web service does authenticate the client when they make direct connections (to the service URI). But why this 401 is being thrown? Perhaps something is missing in the AD setup?
WindowsImpersonationContext context = identity.Impersonate(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.ImpersonationLevel = TokenImpersonationLevel.Delegation; req.UseDefaultCredentials = true; req.AllowAutoRedirect = false; req.Timeout = 30000; HttpWebResponse response = (HttpWebResponse) req.GetResponse();
Software Engineer