开发者

Calling web service with current users credentials from SharePoint

When I run this C# code from my vs2010 client it works authenticating as me.

However if I deploy the code to a sharePoint page on a webserver I get an authentication error from the web service.

I understand this some double hop issue and I need to impersonate. maybe the code is calling the web service as the SharePoint service user.

Any easy way around this beyond hard coding credentials?

Uri uri = new Uri("http://tempuri.org/"); 
ICredentials credentials = CredentialCache.DefaultCredentials; 
NetworkCredential credential = credentials.GetCredential(uri, "Basic"); 
Service service = new S开发者_Python百科ervice("https://xxx/Exchange.asmx", credential);

Someone suggested using windowsidentity class with impersonate, but not sure how to plug that in.

Thanks.


If you are trusted to use the application pool identity to interact with your remote web service then you can use this technique:

http://mindsharpblogs.com/todd/archive/2005/05/03/467.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜