代理身份验证问题

发布于 2024-10-13 05:36:50 字数 1148 浏览 4 评论 0原文

我管理一个内部 SharePoint 门户 (Moss 2007),该门户具有 Web 部件,其中一些从雅虎新闻获取 RSS 提要,而另一些则从雅虎财经(每日股市图表)获取,还有一个从 NOAA 获取当前天气。除雅虎新闻外,所有这些都有效。我得到的错误是:

远程服务器返回错误:(407) 需要代理身份验证。

但是,如果我在我的开发盒 (Win 7) (VS2010) 上本地运行代码作为 Web 应用程序,则新的提要可以正常工作。我知道这是一个身份验证问题,但我无法从 IT 安全人员那里获得任何帮助。

服务器和我的工作站之间的区别在于我使用磁卡登录并针对域进行身份验证。我的电脑使用的浏览器通过代理,该代理列出了一些例外情况,包括 SharePoint 门户。选中绕过本地地址代理。服务器本身被锁定,无法进行任何直接(或通过代理)互联网访问,因此必须对身份验证请求进行编码。

我没有编写此代码,但它在一台服务器上运行良好,但在我的 SharePoint 服务器上则不然。我仔细比较了设置,发现在用作网络小部件的服务器上,它工作得很好。该网站使用域帐户进行模拟。如果我在 SharePoint 中使用模拟,我将使用模拟帐户登录,而不是使用我的凭据。你还在我身边吗?

因此,此代码获取传入的代理服务器信息,但没有任何凭据信息:

WebRequest myRequest = WebRequest.Create(rssURL);
string[] arrProxy = System.Configuration.ConfigurationManager.AppSettings["ProxyServer"].Split(new Char[] { ',' });
myRequest.Proxy = new System.Net.WebProxy(arrProxy[0], Convert.ToInt32(arrProxy[1]));

WebResponse myResponse = myRequest.GetResponse();

Stream rssStream = myResponse.GetResponseStream();
XmlDocument rssDoc = new XmlDocument();
rssDoc.Load(rssStream);

XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");

I manage an internal SharePoint portal (Moss 2007) that has webparts, some of which fetch RSS feeds from yahoo news, while others from yahoo finance (daily stock market charts), yet another one with current weather from NOAA. All of these work except yahoo news. The error I get is:

The remote server returned an error: (407) Proxy Authentication Required.

However, if I run the code locally on my dev box (Win 7) (VS2010) as a web app, the new feed works fine. I understand that this an authentication issue but I can't get any help from our IT security folks.

The difference between the server and my workstation is that I login with a magnetic card and authenticate against the domain. The browser my PC uses goes through a proxy that has some exceptions listed including the SharePoint portal. Bypass proxy for local addresses is checked. The sever itself is locked down from any direct (or via proxy) internet access so the authentication requests have to be coded.

I didn't write this code, but it works fine on one server but will not on my SharePoint server. I have diligently compared setting and found that on a server where it is used as a web widget, it works fine. The web site uses impersonation using a domain account. If I use impersonation in SharePoint, I get logged in with the impersonation account, rather than with my credentials. Are you still with me?

So this code gets the proxy server info fed in but without the any credentials info:

WebRequest myRequest = WebRequest.Create(rssURL);
string[] arrProxy = System.Configuration.ConfigurationManager.AppSettings["ProxyServer"].Split(new Char[] { ',' });
myRequest.Proxy = new System.Net.WebProxy(arrProxy[0], Convert.ToInt32(arrProxy[1]));

WebResponse myResponse = myRequest.GetResponse();

Stream rssStream = myResponse.GetResponseStream();
XmlDocument rssDoc = new XmlDocument();
rssDoc.Load(rssStream);

XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慈悲佛祖 2024-10-20 05:36:50

您能否根据请求设置Credentials

HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Credentials = new NetworkCredential("username", "password", "domain");

我想要么使用您的帐户,要么让 IT 人员创建一个特殊的“server-webaccess”帐户。

Can you set the Credentials on the request:

HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.Credentials = new NetworkCredential("username", "password", "domain");

I guess either with your account, or get the IT guys to create a special "server-webaccess" account.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文