使用java unbounded ldapsdk查询ldap服务器

使用java unbounded ldapsdk查询ldap服务器,java,ldap,ldap-query,unboundid-ldap-sdk,Java,Ldap,Ldap Query,Unboundid Ldap Sdk,我已使用Apache director studio设置了ldap服务器: 这是我的代码: import com.unboundid.asn1.ASN1OctetString; import com.unboundid.ldap.sdk.*; import com.unboundid.ldap.sdk.controls.SimplePagedResultsControl; public class App { /** * @param args * @

我已使用Apache director studio设置了ldap服务器:

这是我的代码:

import com.unboundid.asn1.ASN1OctetString;
import com.unboundid.ldap.sdk.*;
import com.unboundid.ldap.sdk.controls.SimplePagedResultsControl;
public class App {

      /**
       * @param args
       * @throws LDAPException 
       */
      public static void main(String[] args) throws LDAPException {


        LDAPConnection connection = new LDAPConnection("localhost", 10389, "uid=admin,ou=system","secret");//"cn=admin4directory,dc=ilex-si,dc=eu", "M3d2p5a4!");

        //SearchRequest searchRequest = new SearchRequest("ou=people,dc=ilex-si,dc=eu", SearchScope.SUB,"(ixuid=*)");
        SearchRequest searchRequest = new SearchRequest("ou=people,dc=example,dc=com", SearchScope.BASE,Filter.createEqualityFilter("objectClass", "person"));

        ASN1OctetString cookie = null;
       do
       {
         searchRequest.setControls(
              new Control[] { new SimplePagedResultsControl(500, cookie) });
         SearchResult searchResult = connection.search(searchRequest);

         // Do something with the entries that are returned.

         cookie = null;
         for (Control c : searchResult.getResponseControls())
         {
           if (c instanceof SimplePagedResultsControl)
           {
             cookie = ((SimplePagedResultsControl) c).getCookie();
             System.out.println("\ncookie = "+ cookie.toString());
           }
         }
       } while ((cookie != null) && (cookie.getValueLength() > 0));


       connection.close();

      }

    }
我想进行分页查询,但使用此代码我返回了一个空白cookie。。 如何打印cn=john smit和cn robert smith的值

pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>it.abc</groupId>
  <artifactId>LDAPPagedQueryExample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>LDAPPagedQueryExample</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
    <build>
    <plugins>
            <plugin>
                <groupId>org.mule.tools</groupId>
                <artifactId>maven-mule-plugin</artifactId>
                <version>1.6</version>
                <extensions>true</extensions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

        </plugins>
    </build>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.unboundid</groupId>
        <artifactId>unboundid-ldapsdk</artifactId>
        <version>3.1.0</version>
    </dependency>     
            <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>provided</scope>
    </dependency>  
  </dependencies>
</project>

4.0.0
it.abc
LDAPPagedQueryExample
0.0.1-快照
罐子
LDAPPagedQueryExample
http://maven.apache.org
UTF-8
org.mule.tools
maven mule插件
1.6
真的
maven编译器插件
3
1.6
1.6
朱尼特
朱尼特
3.8.1
测试
com.unbounded
未绑定ldapsdk
3.1.0
log4j
log4j
1.2.17
假如

谢谢。

您是否尝试过

当然,您必须至少是SearchScope.ONE或更好的SearchScope.SUB

不确定“如何打印cn=john smit和cn robert smith的值?”,这意味着什么