spring-projects/spring-ldap

No matching response control found

avpdiver opened this issue · 3 comments

I am using OpenLDAP 2.6.7.

POM file looks like this:

 <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>3.2.5</version>
      <relativePath/>
</parent>
<properties>
		<java.version>17</java.version>
</properties>
...
<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-ldap</artifactId>
	</dependency>
        ...
</dependencies>
...

My code:

final var sc = new SearchControls();
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
sc.setTimeLimit(10_000);
sc.setCountLimit(size);
sc.setReturningAttributes(new String[]{"uid", "mail", "cn", "givenName"});

PagedResultsDirContextProcessor processor = null;
var cookie = new PagedResultsCookie(UUID.randomUUID().toString().getBytes());
var currentPage = 0;
do {
        processor = new PagedResultsDirContextProcessor(size, cookie);
        final var results = ldapTemplate
                    .search(
                            "ou=users",
                            "(&(objectClass=person)(uid=*))",
                            sc,
                            (AttributesMapper<UserDtoOut>) attrs -> {
                                final var dto = new UserDtoOut();
                                dto.setUid(getAttribute("uid", attrs));
                                dto.setEmail(getAttribute("mail", attrs));
                                dto.setSurname(getAttribute("sn", attrs));
                                dto.setFirstname(getAttribute("givenName", attrs));
                                return dto;
                            },
                            processor
                    );
        if (currentPage == page) {
             return results;
        }
        cookie = processor.getCookie();
        currentPage++;
} while (processor.hasMore());

And pagination doesn't work. I think because of there are entries in log:
No matching response control found - looking for 'class javax.naming.ldap.PagedResultsResponseControl.