VpnChannel.ActivateForeground(String, ValueSet) 方法

定义

激活前台的 VPN 应用。 这通常用于让用户输入凭据。 只能从 IVpnPlugin.Connect实现调用 ActivateForeground。 当应用处于前台时,常规 Connect 超时将暂停。

如果长时间暂停(约 10 分钟),ActivateForeground 调用将被取消。 如果无法启动,插件应理想地支持不需要用户界面(UI)的身份验证方法。

旨在支持基于 Web 的身份验证方案,例如安全断言标记语言(SAML)和 Azure Active Directory (AAD) 身份验证。

public:
 virtual ValueSet ^ ActivateForeground(Platform::String ^ packageRelativeAppId, ValueSet ^ sharedContext) = ActivateForeground;
ValueSet ActivateForeground(winrt::hstring const& packageRelativeAppId, ValueSet const& sharedContext);
public ValueSet ActivateForeground(string packageRelativeAppId, ValueSet sharedContext);
function activateForeground(packageRelativeAppId, sharedContext)
Public Function ActivateForeground (packageRelativeAppId As String, sharedContext As ValueSet) As ValueSet

参数

packageRelativeAppId
String

Platform::String

winrt::hstring

一个字符串,其中包含要启动的前景应用的包相对应用程序标识符(PRAID)。

sharedContext
ValueSet

ValueSet 对象,用于将信息传递给前台应用。 前台应用可以从激活事件参数访问这些参数。

返回

ValueSet 对象,该对象包含所选的 Windows 运行时对象,该对象从前台应用传回 VPN 插件,指示前台请求的结果。

Windows 要求

设备系列
Windows 11 (在 10.0.22000.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v14.0 中引入)
应用功能
networkingVpnProvider

注解

注意

在 VPN 插件中调用此 API IVpnPlugin.Connect 方法实现将失败。

使用前台激活机制需要在多个位置处理激活。

IVpnPlugin.Connect 方法中,你将使用正确的包相对应用程序标识符(PRAID)和包含要发送到前台应用的所有值的 ValueSet 调用 ActivateForeground

在前台应用中,需要捕获激活。 前台应用将使用 Windows.ApplicationModel.ActivationKind 值为 VpnForeground激活。 激活参数的类型为 Windows.Networking.Vpn.VpnForegroundActivatedEventArgs,并且将包含三个字段。

  1. ProfileName字符串)。
  2. SharedContextValueSet)。
  3. ActivationOperationWindows.Networking.Vpn.VpnForegroundActivationOperationOperation

然后,前台应用可以设置应用的用户界面(UI),以处理所需的授权(或所需的任何数据)。 完成后,必须调用 ActivationOperationComplete 方法,并传入要返回到 IVpnPlugin.Connect 调用的值 ValueSet

返回 IVpnPlugin.Connect 调用,使用从 ActivateForeground 返回的 ValueSet 来确定身份验证是否成功,并处理任何错误。

适用于