VpnChannel.ActivateForeground(String, ValueSet) 方法

定義

在前景啟動 VPN 應用程式。 這通常用來讓使用者輸入認證。 您只能從 IVpnPlugin.Connect實作呼叫 ActivateForeground。 當應用程式處於前景時,會暫停一般 Connect 逾時。

ActivateForeground 呼叫將會取消,如果暫停時間很長(約 10 分鐘)。 如果無法啟動,則外掛程式應該最好支援不需要使用者介面的驗證方法(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 物件,其中包含從前景應用程式傳回至 VPN 外掛程式的 Windows 執行時間物件,表示前景要求的結果。

Windows 需求

裝置系列
Windows 11 (已於 10.0.22000.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v14.0 引進)
應用程式功能
networkingVpnProvider

備註

注意

在 VPN 外掛程式的 IVpnPlugin.Connect 之外呼叫此 API 方法實作將會失敗。

使用前景啟用機制需要處理數個位置的啟用。

在您的 IVpnPlugin.Connect 方法中,您將使用正確的套件相對應用程式識別碼 (PRAID) 和 ValueSet 呼叫 ActivateForeground,其中包含您想要傳送至前景應用程式的所有值。

在前景應用程式中,您需要攔截啟用。 前景應用程式將會以 Windows.ApplicationModel.ActivationKindVpnForeground的值來啟動。 啟用自變數的類型為 Windows.Networking.Vpn.VpnForegroundActivatedEventArgs,且將包含三個字段。

  1. ProfileNameString)。
  2. SharedContextValueSet)。
  3. ActivationOperationWindows.Networking.Vpn.VpnForegroundActivationOperationOperation

然後,前景應用程式可以設定應用程式的使用者介面(UI)來處理所需的授權(或所需的任何數據)。 完成後,您必須呼叫 ActivationOperationComplete 方法,並傳入您想要傳回至 IVpnPlugin.Connect 呼叫之值的 ValueSet

回到 IVpnPlugin.Connect 呼叫中,使用從 ActivateForeground 傳回的 ValueSet 來決定驗證是否成功,並處理任何錯誤。

適用於