Metodo INetwork2::IsDomainAuthenticatedBy (netlistmgr.h)

Esegue una query per verificare se il metodo di autenticazione del dominio specificato è riuscito per la rete.

Sintassi

HRESULT IsDomainAuthenticatedBy(
  NLM_DOMAIN_AUTHENTICATION_KIND domainAuthenticationKind,
  BOOL                           *pValue
);

Parametri

domainAuthenticationKind

Tipo: [in] NLM_DOMAIN_AUTHENTICATION_KIND

Metodo di autenticazione del dominio specifico su cui eseguire query.

pValue

Tipo: [out, retval] BOOL*

La funzione dereferenzia pValue e assegna TRUE se la rete ha lo stesso tipo di autenticazione del dominio specificato nel parametro domainAuthenticationKind oppure FALSE se la rete ha un tipo di autenticazione di dominio diverso da quello specificato in domainAuthenticationKind.

Valore restituito

Restituisce S_OK in caso di esito positivo.

Esempio

In questo esempio, uno strumento ipotetico di diagnostica di rete cerca di garantire che le connessioni a una rete aziendale abbiano proprietà di autenticazione corrette.

void LogToConsole(std::wstring output, std::wstring networkName)
{
	// Implementation not shown for brevity.
}

void RunDiagnostics()
{
	winrt::com_ptr<::INetworkListManager> nlm;
	winrt::com_ptr<::IEnumNetworks> enumNetworks;
	winrt::com_ptr<::INetwork> network;
	ULONG numberOfNetworksEnumerated{ 0 };
	winrt::check_hresult(::CoCreateInstance(CLSID_NetworkListManager, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&nlm)));
	winrt::check_hresult(nlm->GetNetworks(NLM_ENUM_NETWORK_ALL, enumNetworks.put()));

	while ((enumNetworks->Next(1, network.put(), &numberOfNetworksEnumerated) == S_OK))
	{
		try
		{
			if (numberOfNetworksEnumerated == 1)
			{
				winrt::com_ptr<::INetwork2> network2{ network.as<::INetwork2>() };
				BSTR networkName{};
				HRESULT hr{ network2->GetName(&networkName) };
				winrt::check_hresult(network2->GetName(&networkName));

				BOOL isLdapAuthenticated{ FALSE };
				BOOL isTlsAuthenticated{ FALSE };
				BOOL isNotDomainAuthenticated{ FALSE };
				winrt::check_hresult(network2->IsDomainAuthenticatedBy(NLM_DOMAIN_AUTHENTICATION_KIND_LDAP, &isLdapAuthenticated));
				winrt::check_hresult(network2->IsDomainAuthenticatedBy(NLM_DOMAIN_AUTHENTICATION_KIND_TLS, &isTlsAuthenticated));
				winrt::check_hresult(network2->IsDomainAuthenticatedBy(NLM_DOMAIN_AUTHENTICATION_KIND_NONE, &isNotDomainAuthenticated));

				if (!isNotDomainAuthenticated)
				{
					if (!!isLdapAuthenticated)
					{
						LogToConsole(L"Network is domain authenticated via LDAP", networkName);
					}

					if (!!isTlsAuthenticated)
					{
						LogToConsole(L"Network is domain authenticated via TLS", networkName);
					}

					if (!isLdapAuthenticated && !isTlsAuthenticated)
					{
						LogToConsole(L"Network was not expected to be domain authenticated for any other kinds", networkName);
					}
				}
				else
				{
					LogToConsole(L"Network is not domain authenticated", networkName);
				}
			}
		}
		catch (...)
		{
			// Handle exception.
		}
	}
}

Requisiti

Requisito Valore
Client minimo supportato Windows 11 Build 22621
Piattaforma di destinazione Windows
Intestazione netlistmgr.h

Vedi anche