免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4253 | 回复: 2
打印 上一主题 下一主题

[ldap] 该死的1000条限制.... [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-28 14:05 |只看该作者 |倒序浏览
我用的novell的jar包连接的LDAP。可总是查询到1000的时候报错,
代码这样写的。坛子里有人遇见过,解决了也没说清怎么解决,现在我把代码贴上来,谁能帮我看看,我用的IBM的LDAP,novell的jar。
                        
import com.novell.ldap.*;
import java.util.*;

public class test_del{
        @SuppressWarnings("deprecation")
        public static void main(String args[]){
                try{
                        LDAPConnection lc = new LDAPConnection();
                        lc.connect("192.168.0.26",389);
                        lc.bind(LDAPConnection.LDAP_V3,"cn=root","db2admin");
                        System.out.println("asdf");
                LDAPSearchResults lrs = lc.search("cn=users,dc=yourco,dc=com",LDAPConnection.SCOPE_SUB,"objectclass=*",null,true);
                     
                      ArrayList<String> list = new ArrayList<String>();
                      int a = 0;
                while(lrs.hasMore()){
                        System.out.println("        "+a);
                        LDAPEntry entry = lrs.next();
                        a++;
                        System.out.println(a);
                        String DN = entry.getDN();
                        System.out.println(DN);
                }
                for(int i=list.size()-1;i>=0;i--){
                        if(!((String)list.get(i)).equals("dc=zhengxin,dc=com")){
                                lc.delete((String)list.get(i));
                        }else{
                                System.out.println("警告:根目录不可删除...");
                        }
                }
                }catch(Exception e){
                        e.printStackTrace();
                }
        }
}

听说要有个参数设置,在那呢?

[ 本帖最后由 chen_bo 于 2007-8-28 14:10 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-08-31 10:21 |只看该作者
ldap的“搜索返回条目书限制“包括两个方面:服务器端,客户端。

服务器端限制:
        对于Tivoli Directory来说,就是通过ibm-slapdSizeLimit参数是设置。

客户端限制:
        对你们目前的问题而言就是以下语句中的默认Sizelimit是1000.

LDAPConnection lc = new LDAPConnection();
LDAPSearchResults lrs = lc.search("cn=users,dc=yourco,dc=com",LDAPConnection.SCOPE_SUB,"objectclass=*",null,true);


参考以下 novell文档,其中有具体描述.

=================================================

1.http://developer.novell.com/docu ... LDAPConnection.html

LDAPSearchResults search(java.lang.String base, int scope, java.lang.String filter, java.lang.String[] attrs, boolean typesOnly, LDAPSearchConstraints cons)
          Synchronously performs the search specified by the parameters, using the specified search constraints (such as the maximum number of entries to find or the maximum time to wait for search results).

=================================================

2.http://developer.novell.com/docu ... .html#getMaxResults()

getMaxResults
public int getMaxResults()Returns the maximum number of search results to be returned for a search operation. A value of 0 means no limit. Default: 1000 The search operation will be terminated with an LDAPException.SIZE_LIMIT_EXCEEDED if the number of results exceed the maximum.

Returns:
The value for the maximum number of results to return.
See Also:
setMaxResults(int), LDAPException.SIZE_LIMIT_EXCEEDED

=================================================


所以,你可以尝试加入此句.

LDAPConnection lc = new LDAPConnection();
lc.setMaxResults(100000); //
LDAPSearchResults lrs = lc.search("cn=users,dc=yourco,dc=com",LDAPConnection.SCOPE_SUB,"objectclass=*",null,true);
wugc 该用户已被删除
3 [报告]
发表于 2007-09-01 23:56 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP