qw1984java
Deug
2017-03-16 07:54

java获取AD域用户信息 获取的信息只遍历出了1000条

10
  • java
  • ldap
  • 遍历

java获取AD域用户信息 ,获取的信息只遍历出了1000条,想知道实在哪里被限制了吗,正常应该大于1000条

 SearchControls searchCtls = new SearchControls();
        // Specify the search scope
        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        // specify the LDAP search filter
        String searchFilter = "objectclass=*";
        // Specify the Base for the search 搜索域节点
        String searchBase = "DC=wer,DC=com";
        int totalResults = 0;
        String returnedAtts[] = { "objectGUID", "name",
                "userPrincipalName", "DisplayName", "Mail", "telephoneNumber",
                "FacsimileTelephoneNumber", "Title", "Department", "userAccountControl" }; // 定制返回属性

        searchCtls.setReturningAttributes(returnedAtts); // 设置返回属性集
        ArrayList<ArrayList<HashMap<String,String>>> dataList=new ArrayList<ArrayList<HashMap<String,String>>>();
        try {
            NamingEnumeration answer = dc.search(searchBase, searchFilter,searchCtls);

            ArrayList<HashMap<String,String>> grouplist=new ArrayList<HashMap<String,String>>();
            ArrayList<HashMap<String,String>> userlist=new ArrayList<HashMap<String,String>>();
            if (answer == null || answer.equals(null)) {
                System.out.println("answer is null");
            } else {
                System.out.println("answer not null");
            }
            int a= 0;
            while (answer.hasMoreElements()) {
                a++;
                SearchResult sr = (SearchResult) answer.next();
                System.out.println(sr.getName());
                if(sr.getName().contains("OU=qwer")){//只检索带qwer的
                    if(sr.getName().indexOf("OU=") < 0) {
                        continue;
                    }
//                  System.out.println("getname=" + sr.getName());

                    if(!sr.getName().contains("CN=")){//代表是用户组
                         //遍历节点及属性
                         grouplist.add(GroupTag(sr));
                     }else{//是用户
                         //遍历节点及属性
                         userlist.add(UserTag(sr));
                     }
                  }
            }
            System.out.println("一共循环了 :"+a +"次");
``

最后输出结果 一共循环了1000次,为什么是1000次呢?那个地方限制住了?求大神帮忙解答
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

8条回答