gpt4 book ai didi

java - 为什么 SpringLDAP/普通 Java AD 查询中的 accountExpires 和 userAccountControl 过滤器不能按预期工作?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:35:28 25 4
gpt4 key购买 nike

我在基于 spring 的 webapp 中使用 SpringLDAP API 来查询托管在 Windows Server 2012 上的 ActiveDirectory。以下是我的环境详细信息:-Java 1.8.0_101apache-tomcat-8.0.36SpringMVC 4.3.1 & SpringLDAP 2.3.1

以下 AD 过滤器查询在基于 Windows(基于 C++/C#)的查询工具(例如,Lepide AD 查询工具)以及 eclipse IDE 中的 LDAP 浏览器插件中获取匹配帐户,但不获取在 Java(基于 JNDI/SpringLDAP API)代码中以及在基于 Java 的应用程序 JXplorer 中使用时匹配记录/AD 帐户:-

(&(objectclass=user)(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(accountExpires>=131554368000000000)(userPrincipalName=cgm@*))

我正在尝试获取一个活跃的用户帐户,该帐户在给定日期且 userPrincipalName 值以字符串 cgm@ 开头的情况下尚未过期。

以下是 spring-servlet.xml 文件中的 ldap 配置:-

<util:map id="ldapBaseEnvProps">
<entry key="java.naming.ldap.attributes.binary" value="objectGUID"/>
</util:map>
<ldap:context-source id="pooledLdapContextSrc" url="ldap://dc.myadserver.com:3268" base="DC=myadserver,DC=com" username="CN=adusername,OU=Mkt-Managers,DC=myadserver,DC=com" password="*****" base-env-props-ref="ldapBaseEnvProps">
<ldap:pooling max-total="16" max-active="16" max-idle="8" min-idle="0" max-wait="90000" when-exhausted="BLOCK" test-on-borrow="true" test-while-idle="true"/>
</ldap:context-source>

Java/SpringLDAP API 是否完全支持此类 AD 过滤器?如果是,需要更改哪些内容才能使上述 AD 查询过滤器在基于 Java 的代码中工作(获取匹配的 AD 帐户)?

最佳答案

我建议在 Java 中使用 Spring LDAP 的查询构建器对象来帮助您构建该查询。您的问题似乎表明您将该查询从 C (windows) 环境复制到 Java 环境中。

我将首先使用此处使用的 Spring LDAP 中的 .where() 函数构建查询,然后查看它是否会导致相同的错误: https://docs.spring.io/spring-ldap/docs/current/apidocs/org/springframework/ldap/query/LdapQueryBuilder.html

关于java - 为什么 SpringLDAP/普通 Java AD 查询中的 accountExpires 和 userAccountControl 过滤器不能按预期工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47332144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com