【发布时间】:2017-08-11 13:32:00
【问题描述】:
这是我的小测试servlet的代码:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
SearchResult result2 = null;
try {
if (WSSecurityHelper.isServerSecurityEnabled()) {
String testuser = "myuser";
String password = "mypassword";
UserRegistry registry = RegistryHelper.getUserRegistry("LdapRegistry");
response.getWriter().append("<p>Output: " + registry.getUserSecurityName(testuser) +"</p>");
response.getWriter().append("<p>Output: " + registry.isValidUser(testuser) +"</p>");
response.getWriter().append("<p>Output: " + registry.isValidUser(registry.getUserSecurityName(testuser)) +"</p>");
}else{
response.getWriter().append("<p>Output: No Sec Enabled</p>");
}
} catch (Exception e) {
response.getWriter().print("<p>Exception caught: " + e + " </p>");
}
}
这是我 server.xml 中的 LDAP 配置:
<ldapRegistry baseDN="o=appsdir" bindDN="cn=user123,ou=usersbind,o=appsdir" bindPassword="mostsecurePW" host="localhost" id="drd" ldapType="Microsoft Active Directory" port="389" realm="LdapRegistry" recursiveSearch="false" returnToPrimaryServer="true">
<ldapCache>
<attributesCache size="4000"/>
<searchResultsCache resultsSizeLimit="1000" timeout="600ms"/>
</ldapCache>
<activedFilters userFilter="(&(objectClass=person)(|(uid=%v)(samAccountName=%v)(userPrincipalName=%v)))"/>
</ldapRegistry>
我认为我的问题是 server.xml 中的 userFilter 不知何故。 当我将其设置为以下内容时:`
(&(objectClass=person)(|(uid=%v))) <-- on purpose to clarify what was removed
我得到了输出:
Output: uid=testuser,ou=testing,ou=people,o=appsdir
Output: true
Output: false
但是当我将(samAccountName=%v) 和/或(userPrincipalName=%v) 添加到过滤器时,我立即得到以下异常:
Exception caught: com.ibm.websphere.security.CustomRegistryException:
CWIML4520E: The LDAP operation could not be completed. The LDAP naming
exception javax.naming.OperationNotSupportedException: [LDAP: error code 53
- Search is not indexed]; remaining name 'o=appsdir'; resolved object
com.sun.jndi.ldap.LdapCtx@254ba79e occurred during processing.
为什么在使用 | (OR) 时它不起作用?我认为这将通过这个过滤器,直到一个匹配。是否有一些关于其工作原理的文档?
异常中的Search is not indexed 是什么意思?
顺便说一句。使用 userFilter 的标准值也会导致相同的异常。
【问题讨论】:
-
在 ldapsearch 中使用相同的过滤器可能会获得更好/更直接的反馈。我找不到任何提示“拒绝”需要搜索非索引字段的过滤器/搜索的 AD 功能,但可以确定它看起来像什么!
-
谢谢,我从 ldapsearch 得到的信息是一样的
标签: java active-directory ldap websphere-liberty