Java SPRING LDAP-超出ODManager查询返回的大小限制
我正在尝试使用SpringLDAP 1.3.2查询Microsoft Active Directory应用程序模式(ADAM)。我正在使用ODMManager搜索ADAM。我发现了错误Java SPRING LDAP-超出ODManager查询返回的大小限制,java,spring,ldap,Java,Spring,Ldap,我正在尝试使用SpringLDAP 1.3.2查询Microsoft Active Directory应用程序模式(ADAM)。我正在使用ODMManager搜索ADAM。我发现了错误 javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Sizelimit Exceeded]; remaining name '/' at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java
javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Sizelimit Exceeded]; remaining name '/'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3119)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3013)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2820)
文档中不清楚如何使用PagedResultsDirContextProcessor处理ODMManager搜索。非常感谢您的帮助。我使用SpringLDAP 2.0.1.RELEASE成功地实现了这一点。对象目录映射器现在在LdapTemplate中进行管理。我使用自定义ContextMapper在目录上执行搜索。下面列出了映射器和方法
public class UserContextMapper implements ContextMapper {
private static ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{"spring-config.xml"});
public Object mapFromContext(Object ctx) {
Class<User> clazz = User.class;
LdapTemplate ldapTemplate = (LdapTemplate) appContext.getBean("ldapTemplate");
User user = ldapTemplate.getObjectDirectoryMapper().mapFromLdapDataEntry((DirContextOperations) ctx, clazz);
return user;
}
}
公共类UserContextMapper实现ContextMapper{
私有静态ApplicationContext appContext=new ClassPathXmlApplicationContext(新字符串[]{“spring config.xml”});
公共对象mapFromContext(对象ctx){
clazz类=User.Class;
LdapTemplate LdapTemplate=(LdapTemplate)appContext.getBean(“LdapTemplate”);
User User=ldapTemplate.getObjectDirectoryMapper().mapFromLdapDataEntry((DirContextOperations)ctx,clazz);
返回用户;
}
}
public List<User> getLdapQueryResult(final LdapName dn, final Filter filter) throws NamingException {
final PagedResultsDirContextProcessor processor = new PagedResultsDirContextProcessor(getPageSize());
final SearchControls searchControls = new SearchControls();
final UserContextMapper ucm = new UserContextMapper();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
return SingleContextSource.doWithSingleContext(
ldapTemplate.getContextSource(), new LdapOperationsCallback<List<User>>() {
@Override
public List<User> doWithLdapOperations(LdapOperations operations) {
List<User> result = new LinkedList<User>();
do {
List<User> oneResult = operations.search(dn, filter.encode(), searchControls, ucm, processor);
result.addAll(oneResult);
} while (processor.hasMore());
return result;
}
});
}
public List getLdapQueryResult(最终LdapName dn,最终筛选器)引发NamingException{
final PagedResultsDirContextProcessor=新的PagedResultsDirContextProcessor(getPageSize());
最终SearchControls SearchControls=新的SearchControls();
最终用户上下文映射器ucm=新用户上下文映射器();
searchControls.setSearchScope(searchControls.SUBTREE_范围);
返回SingleContextSource.doWithSingleContext(
ldapTemplate.getContextSource(),新的LdapOperationsCallback(){
@凌驾
公共列表doWithLdapOperations(LDAPERATIONS操作){
列表结果=新建LinkedList();
做{
List oneResult=operations.search(dn,filter.encode(),searchControls,ucm,processor);
结果:addAll(oneResult);
}while(processor.hasMore());
返回结果;
}
});
}