views:

16

answers:

1

Here is my problem, I have one webpart that will retrieve current username and its token, using this code: SPUser myUser = SPControl.GetContextWeb(Context).CurrentUser;

This information will be forwarded to external system, that will invoke windows service to download a document in sharepoint using sharepoint webservice.

The problem is: How I can access the webservice with only user login name & SpUser's token?

I already try to impersonate, the windows service to act like given user login name, but no luck, I got "An attempt was made to access a socket in a way forbidden by its access permissions" throw by System.Net.HttpWebRequest.GetResponse() method.

Any idea how to solve this?

A: 

I don't think you need to impersonate since you'd be executing within the context of the current user. You would simply use CredentialCache.DefaultNetworkCredentials when you need to provide NetworkCredentials to the service.

However, if you find you still need to impersonate this other answer may be helpful.

Kit Menke