为 webview 控件提供域/用户凭据 [英] providing domain/user credentials to webview control

查看:38
本文介绍了为 webview 控件提供域/用户凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何为 WebView 控件提供凭据(或者甚至更好 - 在特定域用户的上下文中运行 Windows 8 Metro 风格应用程序/WinRT 应用程序?)我尝试按照 HttpClient + WebView 方法作为此处列出(http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/05e46a0a-e913-469d-a4a5-4a805dcf158a)但它仍然提示用户输入凭据,因为在返回的内容中是指向受保护项目的链接.

Does anyone know how to provide credentials to a WebView control (or even better - run a Windows 8 Metro style application / WinRT app in the context of a specific domain user?) I've tried following the HttpClient + WebView approach as listed here (http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/05e46a0a-e913-469d-a4a5-4a805dcf158a) but it still prompts the user for credentials, since in the returned content there are links to secured items.

我有一个 NetworkCredential 对象,我非常想将它应用到每个 HTTP 调用.

I have a NetworkCredential object, and I pretty much want to apply it to every single HTTP call that gets made.

肯定有人以前做过吗?:)

Surely someone must have done this before? :)

推荐答案

为了连接到您公司网络上的站点,您必须在 Package.appxmanifest 中启用 privateNetworkClientServer 功能强>.您可以在 XML 中执行此操作,也可以在 Visual Studio 中双击文件并使用设计器(功能选项卡).在 UI 中称为家庭或工作网络".

In order to connect to sites on your corporate network you must enable the privateNetworkClientServer capability in your Package.appxmanifest. You can do this in the XML or you can double-click on the file in Visual Studio and use the designer (capabilities tab). In the UI it's called "Home or Work Networking".

现在您可以访问 Intranet,您可以导航到该站点,但系统会提示您提供凭据.如果您希望自动提供用户域身份(企业单点登录),您还需要启用 enterpriseAuthentication 功能.这在清单 UI 中称为企业身份验证".

Now that you have access to the intranet you can navigate to the site but you will be prompted to provide credentials. If you want the users domain identity to automatically be supplied (enterprise single sign on) you need to enable the enterpriseAuthentication capability as well. This is called "Enterprise Authentication" in the manifest UI.

从那里您应该能够使用 WebView 浏览到任何 Intranet 站点,而不必进行身份验证.如果您希望在 WebView 之外做一些事情,您应该查看以下文章和示例:

From there you should be able to browse to any intranet site using a WebView and not have to authenticate. If you are looking to do things outside of the WebView, you should check out the following articles and samples:

使用 WebAuthenticationBroker:

Using WebAuthenticationBroker:

http://code.msdn.microsoft.com/windowsapps/Web-认证-d0485122

WebAuthenticationBroker 有一个名为 UseCorporateNetwork 的选项.在按照上面的示例进行操作时,请务必使用它.

WebAuthenticationBroker has an option called UseCorporateNetwork. Make sure to use that when following along in the sample above.

最后,如果您想使用 Facebook 或 Flicr 等其他网站进行单点登录,请参阅此示例:

Finally, if you want to do Single Sign On with other sites like Facebook or Flicr, see this sample:

http://msdn.microsoft.com/en-美国/图书馆/windows/apps/xaml/Hh465283

这篇关于为 webview 控件提供域/用户凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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