使用SharePoint中的当前用户凭据调用Web服务 [英] Calling web service with current users credentials from SharePoint

查看:204
本文介绍了使用SharePoint中的当前用户凭据调用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从我的vs2010客户端运行这个C#代码时,它可以像我一样进行身份验证。

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

但是,如果我将代码部署到网络服务器上的sharePoint页面,我会得到一个来自Web服务的身份验证错误。

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

我理解这个双跳问题,我需要冒充。也许代码是以SharePoint服务用户的身份调用Web服务。

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 Service("https://xxx/Exchange.asmx", credential);

有人建议使用带有模仿的windowsidentity类,但不知道如何将其插入。

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

谢谢。

推荐答案

如果您信任使用应用程序池标识进行交互使用您的远程Web服务,您可以使用此技术:

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

这篇关于使用SharePoint中的当前用户凭据调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆