Delen via


ConnectionProfile.IsDomainAuthenticatedBy(DomainAuthenticationKind) Method

Definition

Queries whether the specified domain authentication method succeeded for this connection profile.

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

Parameters

kind
DomainAuthenticationKind

The specific domain authentication method to query about.

Returns

Boolean

bool

true if this connection profile has the same domain authentication kind as that specified in the kind parameter; false if this connection profile has a different domain authentication kind from that specified in kind.

Windows requirements

Device family
Windows 11 Insider Preview (introduced in 10.0.23504.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v15.0)

Examples

The scenario for this code example is that a networking diagnostic tool for IT admins wants to ensure that connections to a corporate network have the correct authentication properties.

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);
        }
    }
}

Applies to