ConnectionProfile.IsDomainAuthenticatedBy(DomainAuthenticationKind) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
查询此连接配置文件的指定域身份验证方法是否成功。
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
参数
要查询的特定域身份验证方法。
返回
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);
}
}
}