查询广告以获取无限结果 [英] Query to AD for unlimited results

查看:110
本文介绍了查询广告以获取无限结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下一个代码来获取广告中的所有用户

I am using the next code to get all the users in the AD

Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://grupoasisa.local:636");
    env.put(Context.SECURITY_PROTOCOL, "ssl");
    env.put(Context.SECURITY_PRINCIPAL, "DOMASISA\\"+USER_SERVICE);
    env.put(Context.SECURITY_CREDENTIALS, PASSWORD_SERVICE);

    try {
        DirContext ctx = new InitialLdapContext(env, null);

        SearchControls searchCtls = new SearchControls();

        String returnedAtts[]={"sAMAccountName", "description", "mail"};

        searchCtls.setReturningAttributes(returnedAtts);

        //Specify the search scope
        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        searchCtls.setTimeLimit(0);
        searchCtls.setCountLimit(0);

        //Specify the LDAP search filter
        String searchFilter="(&(objectCategory=person)(objectClass=user))";
        //Specify the Base for the search
        String searchBase = "DC=grupoasisa,DC=local";

        // Search for objects using the filter
        NamingEnumeration<SearchResult> answer = ctx.search(searchBase, searchFilter, searchCtls);

        //Loop through the search results
        while (answer.hasMoreElements()) {
            SearchResult searchResult = answer.next();
            Attributes attrs = searchResult.getAttributes();
            Attribute usuWin = attrs.get("sAMAccountName");
            Attribute racf = attrs.get("description");
            Attribute email = attrs.get("mail");    
        }
} catch (NamingException e) {
        System.err.println("Error: "+e.getMessage());
    } catch (Exception e) {
        System.err.println("Error: "+e.getMessage());
    }

尽管我指定了搜索,但我只收到1000条第一条记录是无限的。怎么了?

And I am receiving only the 1000 first records although I was specifying that the search was unlimited. What is happening?

预先感谢。

推荐答案

不可能,您必须通过结果分页(PaginationControl)。尝试答案。

Not possible, you have to paginate (PaginationControl) through the results. Try this answer.

这篇关于查询广告以获取无限结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆