【发布时间】: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