LDAP的SizeLimitExceededException
来源:互联网 发布:数据信息加工 编辑:程序博客网 时间:2024/06/06 03:23
LDAP.search()当查询的数据较多时,数据条目大于LDAP服务器设置的最多数据时,就会出现SizeLimitExceededException。
解决方法之一是分页查询,控制每次查询的数目。
- public void getAllPerson() throws NamingException, IOException {
- SearchControls schCtrls = new SearchControls();
- // 返回属性
- String[] returnAttrs = { "userPrincipalName", "distinguishedName" };
- schCtrls.setReturningAttributes(returnAttrs);
- schCtrls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- int pageSize = 100;
- byte[] cookie = null;
- ContextSource contextSource = ldapTemplate.getContextSource();
- DirContext ctx = contextSource.getReadWriteContext();
- LdapContext lCtx = (LdapContext) ctx;
- lCtx.setRequestControls(new Control[] { new PagedResultsControl(
- pageSize, Control.CRITICAL) });
- int totalResults = 0;
- do {
- AndFilter andF = new AndFilter();
- andF.and(new EqualsFilter("objectclass", "person")).and(
- new LikeFilter("userPrincipalName", "*"));
- NamingEnumeration<SearchResult> results = lCtx.search("",
- andF.toString(), schCtrls);
- while (results != null && results.hasMoreElements()) {
- SearchResult sr = results.next();
- Attributes attrs = sr.getAttributes();
- System.out.println(attrs.get("userPrincipalName").get());
- System.out.println(attrs.get("distinguishedName").get());
- totalResults++;
- }
- cookie = parseControls(lCtx.getResponseControls());
- lCtx.setRequestControls(new Control[] { new PagedResultsControl(
- pageSize, cookie, Control.CRITICAL) });
- } while ((cookie != null) && (cookie.length != 0));
- lCtx.close();
- System.out.println("Total" + totalResults);
- }
- private static byte[] parseControls(Control[] controls)
- throws NamingException {
- byte[] cookie = null;
- if (controls != null) {
- for (int i = 0; i < controls.length; i++) {
- if (controls[i] instanceof PagedResultsResponseControl) {
- PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i];
- cookie = prrc.getCookie();
- System.out.println(">>Next Page \n");
- }
- }
- }
- return (cookie == null) ? new byte[0] : cookie;
- }
转自:http://blog.csdn.net/whuqin/article/details/7448531
0 0
- LDAP的SizeLimitExceededException
- LDAP的SizeLimitExceededException
- 上传文件过大的问题FileUploadBase$SizeLimitExceededException
- 上传文件过大的问题FileUploadBase$SizeLimitExceededException
- 上传文件过大的问题FileUploadBase$SizeLimitExceededException
- 转:上传文件过大的问题FileUploadBase$SizeLimitExceededException
- 什么是LDAP?LDAP目录的优势
- 【LDAP】关于LDAP的objectClass及Attribute
- 学习LDAP的过程
- LDAP的详细介绍
- LDAP的详细介绍
- Linux下的LDAP
- 理解LDAP的Attribute
- LDAP的objectClass
- ldap的学习
- Linux下的LDAP
- LDAP服务器的安装
- LDAP的objectClass
- WordPress更改固定链接出现404错误
- 访问控制
- vimtutor总结
- Yii框架实现MySQL多库和主从分离
- 详细配置说明||Spring 使用注解方式进行事务管理
- LDAP的SizeLimitExceededException
- Android Native Development Kit (NDK)
- ios 文件目录结构
- View.setTag()的作用
- 关于NoSQL
- MongoDB查询
- Sublime Text 2 快捷键用法大全
- 03. 类型、存储和变量
- C++之(ofstream,ifstream,fstream)