LDAP の検索に UnboundId SDK を使用し、結果のページングに SimplePagedResultsControl を使用しています。ページ サイズに基づいて適切に検索し、目的の結果の最初のセットを取得できますが、SearchResult からの応答制御オブジェクトが NULL であるため、後続の結果セットを取得できません。残りの結果の取得を続行するには、Cookie の値を取得し、検索要求の次の検索要求に設定する必要があります。
UnboundId SDK Web サイトや他のサイトで提供されている同様のコードを使用しています。これを解決するための助けをいただければ幸いです。
// Perform a search to retrieve all users in the server, but only retrieving
// ten at a time.
int numSearches = 0;
int totalEntriesReturned = 0;
SearchRequest searchRequest = new SearchRequest("dc=example,dc=com",
SearchScope.SUB, Filter.createEqualityFilter("objectClass", "person"));
ASN1OctetString resumeCookie = null;
while (true)
{
searchRequest.setControls(
new SimplePagedResultsControl(10, resumeCookie));
SearchResult searchResult = connection.search(searchRequest);
numSearches++;
totalEntriesReturned += searchResult.getEntryCount();
for (SearchResultEntry e : searchResult.getSearchEntries())
{
// Do something with each entry...
}
LDAPTestUtils.assertHasControl(searchResult,
SimplePagedResultsControl.PAGED_RESULTS_OID); -*Failing here as the SearchResult obj
is not having any Response Control*
SimplePagedResultsControl responseControl =
SimplePagedResultsControl.get(searchResult);
if (responseControl.moreResultsToReturn())
{
// The resume cookie can be included in the simple paged results
// control included in the next search to get the next page of results.
resumeCookie = responseControl.getCookie();
}
else
{
break;
}
}