LDAP的SizeLimitExceededException
来源:互联网 发布:python 2.6 2.7 编辑:程序博客网 时间:2024/06/03 13:39
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;}
其中的cookie是告诉服务器目前已获得的条数,便于下页获取。
- 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
- 敏捷外包工程系列之四:合理选择质量管理的等级(一)
- 笔试题目3 字符串比较函数 int strcmp(const char* str1,const char *str2)
- PHP SOCKET编程
- 再次探究Unicode与ASCII编码
- Android ramdisk.img system.img userdata.img 介绍与使用
- LDAP的SizeLimitExceededException
- xp 系统CMD 批处理命令大全 cmd.exe
- jQuery实现的瀑布流效果, 向下滚动即时加载内容
- 位运算用例
- reportlab 中文問題
- Linux中断解析
- 提高PHP代码质量的36个技巧
- C++中的位拷贝和值拷贝
- Qt界面字体大小设置和更改字体