【问题标题】:Spring's LdapTemplate search: PartialResultException: Unprocessed Continuation Reference(s); remaining name '/'Spring 的 LdapTemplate 搜索:PartialResultException: Unprocessed Continuation Reference(s);剩下的名字'/'
【发布时间】:2016-05-27 14:34:23
【问题描述】:

我通过 LDAP 为某个使用 spring 制作的应用程序添加用户。

虽然这适用于大多数情况,但在某些情况下,它不起作用......

检索我使用的用户:

public class LdapUserServiceImpl implements ILdapUserService {

    @Override
    public List<LdapUserVO> getUserNamesByQuery(String query) {
        return ldapTemplate.search(
            query().countLimit(15)
                    .where("objectClass").is("user")
                    .and("sAMAccountName").isPresent()
                    .and(query()
                            .where("sAMAccountName").like("*" + query + "*")
                            .or("sAMAccountName").is(query)
                            .or("displayName").like("*" + query + "*")
                            .or("displayName").is(query))
            ,
            new AttributesMapper<LdapUserVO>() {
                public LdapUserVO mapFromAttributes(Attributes attrs) throws NamingException {
                    LdapUserVO ldapUser = new LdapUserVO();
                    Attribute attr = attrs.get(ldapUserSearch);
                    if (attr != null && attr.get() != null) {
                        ldapUser.setUserName(attr.get().toString());
                    }
                    attr = attrs.get("displayName");
                    if (attr != null && attr.get() != null) {
                        ldapUser.setDisplayName(attr.get().toString());
                    }
                    return ldapUser;
                }
            });
    }
}

所以这在大多数情况下都有效,但有时我会收到以下错误:

unprocessed continuation reference(s); remaining name "/"

我已经搜索了很多关于这个,我明确设置

DefaultSpringSecurityContextSource ctxSrc = new DefaultSpringSecurityContextSource(ldapUrl);
ctxSrc.setReferral("follow");

更多信息:

  • 搜索查询“admin_a”有效,但“admin_ah”无效
  • Spring 版本是 4.2.5.RELEASE
  • Spring ldap-core 版本为 2.0.2.RELEASE

我觉得奇怪的是剩下的名字是根目录...有人知道如何解决这个问题,甚至从哪里开始寻找吗?

提前致谢!

【问题讨论】:

    标签: spring ldap spring-ldap ldap-query ldap-client


    【解决方案1】:

    这可能与 Active Directory 无法自动处理引用有关。请看LdapTemplate javadoc

    如果是这种情况,请在您的 ldapTemplate 配置中将 ignorePartialResultException 属性设置为 true

    【讨论】:

    • 我可以在application.properties 中设置这个属性吗 - 使用 Spring Boot?
    • 不幸的是你不能。您可以在application.properties 中定义自定义属性,但您仍需要将其传递给org.springframework.ldap.core.LdapTemplate.setIgnorePartialResultException(boolean) 以使其生效。
    【解决方案2】:

    在我的案例中出现此错误的原因是新 AD 的结构已更改(userPrincipleName 现在是电子邮件地址而不是登录名)。因此,对 AD 的身份验证工作正常,但找不到与过滤器匹配的条目,因此没有返回任何结果。 所以 PartialResultException 只是一个指示,而不是原因。原因是 SpringSecurityLdapTemplate 类的 searchForSingleEntryInternal 方法没有任何结果。 就我而言,我必须确保我使用了正确的 userPrincipleName 并在我的 ActiveDirectoryLdapAuthenticationProvider 中配置了正确的域和 baseDN。

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 1970-01-01
      • 1970-01-01
      • 2016-10-23
      • 2014-10-05
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多