Asynchronous Web Services calls with Impersonation

Asynchronous Web Services calls with Impersonation

Post by Dave » Mon, 30 Jul 2007 02:49:21


Hello,

I have a problem with Impersonation with ASPX pages running with
Impersonation that call Web Services Asynchonously that the
Impersonated credentials are not passed to the Web Service when called
with the Begin... method, however they are when the Web Service is
called normally.

Microsoft .NET 2, Visual Studio 2005 Pro

-- SAMPLE ASPX Page --
Dim oService As New samplews.SampleService
oService.Credentials =
System.Net.CredentialCache.DefaultCredentials
oService.BeginWhoAmI(AddressOf callback, Nothing)


-- SNIPPET FROM THE SAMPLE WEB SERVICE --
<WebMethod()> _
Public Sub WhoAmI()
Dim oSR As New System.IO.StreamWriter("c:\temp
\wswhoami.txt", True)
oSR.WriteLine(My.User.Name)
oSR.Close()
End Sub


The subroutine - when run on Windows XP reports back as
COMPUTERNAME\ASPNET.


I can work around the problem by editing the ASPNET.CONFIG file,
however I don't like this idea as this will effect all applications
and the application I develop may well have to run alongside other Web
Applications (I got the idea to try this from
http://www.yqcomputer.com/ )


<configuration>
<runtime>
<alwaysFlowImpersonationPolicy enabled="true"/>
<legacyImpersonationPolicy enabled="false"/>
</runtime>
</configuration>


Is there another way to pass my current credentials to the Web Service
when run Asyncronously? If I could send the Web Service my
System.Security.Principal.WindowsIdentity.GetCurrent() I could
run .Impersonate against it but I'm not sure how to send this Object
to the Web Service


Help!



Regards,



David Homer
 
 
 

1. InvocationTargetException when calling "new Service()" in Axis web service to call another web service

2. CLR calling a web service and AppPool impersonation - weird issue

Hi. Crossposted because the issue seems bizzare and I have no idea
where the problem lies.

We have a CLR that calls ASP.NET Web Service using NetworkCredentials
to pass in login, passowrd and domain of a domain user.
Application and apppool housing the webservice run under network
service; IIS6 on WIn2003 is used; windows auth is used; and everything
works fine.
If you check IIS logs you see POST request to web service resulting in
401 error immediately followed by the call with user supplied and WS
procedure does launch.

As soon as you change the App Pool that houses the application to run
under the specific user (the same user that is used for Web Service
auth), CLR s/WS method combo stops working.
There are no errors; if you check the logs there's a user-less WS call
resulting in 401 but second successful call is not longer there.

How do we fix this?

3. Call Custom Web Service from Plugin with impersonation

4. Calling Web Service that calls other Web Service with Windows Authentication

5. Calling Web Service that calls other Web Service with Windows Auth

6. Calling Web Service that calls other Web Service with Windows Authentication

7. Impersonation not working with Asynchronous calls

8. Asynchronous web service calls by TCP

9. Asynchronous calling problem in Web service.

10. Asynchronous Web Service Calls with asp.net???

11. asynchronous web service call

12. return xml from asynchronous web service to calling page?

13. Asynchronous calls to a web service - 100,000 a minute

14. Calling An Asynchronous Web Service from UI Thread