views:

204

answers:

1

Fails:

//Note: webserviceProxy inherits from SoapHttpClientProtocol
//App Pool is running as a user with permissions to call the external webservice

var webserviceProxy = new webServiceProxy();

webserviceProxy.PreAuthenticate = true;
webserviceProxy.UseDefaultCredentials = true;

var returnVal = webServiceProxy.DoSomething();  //Fails with 401, webserviceProxy.Credendials shows an empty username, pass, and domain

Works:

//This code works, but I want to assign the current app pool's credentials to the webservice proxy's credentials.  UsingDefaultCredentials doesn't work.  The username, passoword, and domain are always null.

var webserviceProxy = new webServiceProxy();

webserviceProxy.PreAuthenticate = true;
webserviceProxy.Credentials = new NetworkCredential("user", "pass", "domain");

var returnVal = webServiceProxy.DoSomething();  //Fails with 401

How can I make an external webservice call using the identtity of ASP.NET's app pool? There doesn't seem to be a way to convert System.Security.Principal.WindowsIdentity.GetCurrent() to something I can use for this call.

Thanks!