INetwork2::IsDomainAuthenticatedBy 方法 (netlistmgr.h)
查詢此網路的指定網域驗證方法是否成功。
語法
HRESULT IsDomainAuthenticatedBy(
NLM_DOMAIN_AUTHENTICATION_KIND domainAuthenticationKind,
BOOL *pValue
);
參數
domainAuthenticationKind
類型:[in] NLM_DOMAIN_AUTHENTICATION_KIND
要查詢的特定網域驗證方法。
pValue
類型: [out, retval] BOOL*
函式會取值 pValue,並指派 TRUE
此網路是否具有與 domainAuthenticationKind 參數中指定的相同網域驗證種類;如果 FALSE
此網路與 domainAuthenticationKind 中指定的網域驗證種類不同,則為 。
傳回值
如果成功 , 則傳回S_OK。
範例
在此範例中,假設的網路診斷工具會尋求確保與公司網路的連線具有正確的驗證屬性。
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.
}
}
}
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | Windows 11 組建 22621 |
目標平台 | Windows |
標頭 | netlistmgr.h |