开发者

Calling web service with current users credentials from SharePoint

开发者 https://www.devze.com 2023-03-30 07:02 出处:网络
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.

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

精彩评论

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

关注公众号