views:

824

answers:

2

I'm sure there's an elegant solution to the problem but I just can't get my head around it. I am trying to call a web service from within a Windows service. The web service is secured (using Windows authentication). The account that the windows service runs under does have the rights to call the web service but I can't figure out how to get those credentials and send them off to the web service. The web service is WCF and is hosted on the same machine (in IIS) as the windows service.

+6  A: 

You should be able to use something like this:

var myService = new myThing.Service();
myService.Credentials = System.Net.CredentialCache.DefaultCredentials;
Steven Robbins
A: 

Have you tried enabling integrated authentication (NTLM) for IIS? In my view that should allow you to call web service if the windows service user account has rights to invoke the service. you need not explicitly extract credentials.

Rutesh Makhijani