首页 > 解决方案 > DirectorySearcher() 和 AuthenticationTypes 枚举

问题描述

使用参数实例化DirectorySearcher(doman,...)时,您可以指定AuthenticationTypes。但是,在没有参数的情况下实例化DirectorySearcher()时,不清楚将使用 什么AuthenticationTypes 。

现在这是一件大事,因为使用 NTLM 的AuthenticationTypes.secure将在接下来的几个月被 MS 在 MS AD 服务器上废弃和禁用。这让开发人员争先恐后地取消他们的 SW

我的猜测是在没有参数的情况下实例化 DirectorySearcher() 时,调用代码会找到第一个合适的 AuthenticationType,因此现有代码不会中断。但我想确认..

标签: active-directoryldap

解决方案


默认值为AuthenticationTypes.Secure,您可以从源代码或检查AuthenticationType属性中看到:

Console.WriteLine(new DirectoryEntry().AuthenticationType);

但是,AuthenticationTypes.Secure只是尝试 NTLM。文档说:

请求安全身份验证。设置此标志时,WinNT 提供程序使用 NTLM 对客户端进行身份验证。Active Directory 域服务使用 Kerberos,可能还有 NTLM,对客户端进行身份验证。当用户名和密码为空引用(Nothing在 Visual Basic 中)时,ADSI 使用调用线程的安全上下文绑定到对象,该安全上下文是运行应用程序的用户帐户或客户端的安全上下文调用线程正在模拟的用户帐户。

对于 Active Directory 域服务,它实际上更喜欢 Kerberos 而不是 NTLM。


推荐阅读