【问题标题】:Liberty WebApp Active Directory authenticationLiberty WebApp Active Directory 身份验证
【发布时间】: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="(&amp;(objectClass=person)(|(uid=%v)(samAccountName=%v)(userPrincipalName=%v)))"/>
</ldapRegistry>

我认为我的问题是 server.xml 中的 userFilter 不知何故。 当我将其设置为以下内容时:`

(&amp;(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


【解决方案1】:

所以,我在userSecurityName 上使用了以下过滤器并使用了isValidUser 方法: (&amp;amp;(|(objectcategory=person)(objectclass=person))(uid=%v)) (liberty的server.xml文件需要amp;,否则不需要)

我不知道为什么或如何在 AD 中进行检查,但使用 userSecurityName 时似乎没有 objectclass=person,但有 objectcategory=person。 不使用 userSecurityName 时似乎也是如此,但反过来,似乎也是如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 2015-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多