共用方式為


ConnectionProfile.IsDomainAuthenticatedBy(DomainAuthenticationKind) 方法

定義

查詢此連線設定檔的指定網域驗證方法是否成功。

public:
 virtual bool IsDomainAuthenticatedBy(DomainAuthenticationKind kind) = IsDomainAuthenticatedBy;
bool IsDomainAuthenticatedBy(DomainAuthenticationKind const& kind);
public bool IsDomainAuthenticatedBy(DomainAuthenticationKind kind);
function isDomainAuthenticatedBy(kind)
Public Function IsDomainAuthenticatedBy (kind As DomainAuthenticationKind) As Boolean

參數

kind
DomainAuthenticationKind

要查詢的特定網域驗證方法。

傳回

Boolean

bool

true 如果此連線設定檔與 kind 參數中指定的網域驗證種類相同,則為 ; false 如果此連線設定檔與 種類指定的網域驗證種類不同,則為 。

Windows 需求

裝置系列
Windows 11 Insider Preview (已於 10.0.23504.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v15.0 引進)

範例

此程式碼範例的案例是 IT 系統管理員的網路診斷工具想要確保與公司網路的連線具有正確的驗證屬性。

using Windows.Networking.Connectivity;

...

public class Diagnostics
{
    private async void LogToConsole(string output, string connectionProfileName)
    {
        // Implementation omitted for brevity.
    }

    public async void RunDiagnostics()
    {
        // Retrieve the ConnectionProfile.
        ConnectionProfile internetConnectionProfile =
            NetworkInformation.GetInternetConnectionProfile();
        if (internetConnectionProfile == null)
        {
            LogToConsole("Device isn't connected to a network", "");
            return;
        }

        string connectionProfileName =
            internetConnectionProfile.ProfileName;
        bool isDomainAuthenticated =
            !internetConnectionProfile.IsDomainAuthenticatedBy(DomainAuthenticationKind.None);
        bool isLdapAuthenticated =
            internetConnectionProfile.IsDomainAuthenticatedBy(DomainAuthenticationKind.Ldap);
        bool isTlsAuthenticated =
            internetConnectionProfile.IsDomainAuthenticatedBy(DomainAuthenticationKind.Tls);

        if (isDomainAuthenticated)
        {
            if (isLdapAuthenticated)
            {
                LogToConsole("Connection profile is domain-authenticated via LDAP",
                    connectionProfileName);
            }
            if (isTlsAuthenticated)
            {
                LogToConsole("Connection profile is domain-authenticated via TLS",
                    connectionProfileName);
            }

            if (!isLdapAuthenticated && !isTlsAuthenticated)
            {
                LogToConsole("Connection profile wasn't expected to be domain authenticated for any other kinds",
                    connectionProfileName);
            }
        }
        else
        {
            LogToConsole("Connection profile isn't domain-authenticated",
                connectionProfileName);
        }
    }
}

適用於