【发布时间】:2021-03-06 16:58:38
【问题描述】:
我首先要说的是,很遗憾,我无法在这种特定情况下更改代码,并且代码在除此安装之外的任何地方都可以使用。我怀疑存在配置/权限/信任问题,我希望获得有关如何修改环境以解决此问题的建议。
在这个特定的地方,在LdapConnection 上运行Search() 方法后,由于某种原因,我得到一个不包含LdapSearchResult 的LdapSearchQueue。请注意LdapSearchQueue 确实包含其他消息(特别是LdapSearchResultReference 和LdapResponse),而不是LdapSearchResult。我可以手动检查 AD,看看理论上它应该有正确的响应。
显然,它最终以 entry 为 null。
var filter = $"(&(objectClass=User)(sAMAccountName={<user_name>}))";
var searchBase = "DC=<domain_name>,DC=com";
var search = conn.Search(searchBase, LdapConnection.SCOPE_SUB, filter, null, false, null, null);
LdapMessage message;
LdapEntry entry = null;
while ((message = search.getResponse()) != null)
{
if (!(message is LdapSearchResult searchResultMessage))
{
continue;
}
entry = searchResultMessage.Entry;
}
感谢任何建议
【问题讨论】:
-
好吧,我们没有看到任何绑定和过滤器。此外,可能根本没有匹配项。您是否尝试过使用具有相同身份验证和过滤器的 LDAP 浏览器?
-
@schnitz77。谢谢..我更新了问题:我没有添加绑定/过滤器,因为它有效/应该有效,但我正在添加过滤器。我还注意到
LdapSearchQueue确实包含其他消息(特别是LdapSearchResultReference和LdapResponse),而不是LdapSearchResult。我可以手动检查 AD,看看理论上它应该有正确的响应。 -
谢谢。当您提到 Novell 时,我有点困惑 - 您要查询的是 eDirectory 还是 Active Directory?根据安装的目录扩展,前者不一定有 sAMAccountName。
-
@schnitz77:这是活动目录。如果 AD 未配置为具有 sAMAccountName,那么它会无法在
LdapSearchQueue中获取任何内容吗?我们确实在搜索结果中收到了一些消息:只是缺少特定消息。 -
好的,现在知道了,您正在使用 NuGet 包 Novell.Directory.Ldap 查询 Active Directory,很抱歉造成混淆。如果它是 Windows 2000 之前的域,我想您不会得到任何匹配,但这与您的手动检查不匹配。