views:

758

answers:

1

I have a ASP 3.5 web forms app using windows authentication that needs to call a soap based web service (the SSRS 2005 report service) which uses integrated windows authentication. However the call to the web service from the asp backend keeps throwing a 401 error. If I turn on anonymous authenticatoin on the web service it works ok using the IUSR_xxx account however I want it to connect using the windows account of the user accessing the asp web app. How can I pass through the windows user credentials?

+3  A: 

Hi,

you have to authenticate your webservice by supplying the default credential to your proxy. like this

localhost.ServiceX myProxy = new localhost.ServiceX();
myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

cheers

Ramesh vel

Ramesh Vel
yeah tried that but it the same 401 error is returned, the DefaultCredentials doesn't seem to contain the credentials of the current windows user
Chris Herring
Ok that worked however I also needed to explicitly set the ImpersonationLevel property on the web service proxy WebRequest object to Impersonation. By default it was set to Delegation.
Chris Herring
You can also use: myProxy.UseDefaultCredentials = True
davidsleeps