I have to search modified (add, delete, modify) entries using ContentSyncRequestControl
in Unboundid sdk, but it showing all the entries instate of modified entries.
what I have done so far
LDAPConnection ldapConnection = null;
try {
/*Apache LDAP*/
ldapConnection = new LDAPConnection("192.168.0.0", 389);
ldapConnection.bind("uid=test,ou=system", "mypassword");
Scanner sc = new Scanner(System.in);
ASN1OctetString cookie = null;
int choice = 3;
while (true) {
SearchRequest searchRequest = new SearchRequest(ldapConnection
.getRootDSE().getAttributeValue("namingContexts"),
SearchScope.SUB, "(&(objectclass=person))",
"createTimestamp","modifyTimestamp","sn","mobile","givenName","ucMiddleName","mail",
"isDeleted");
ContentSyncRequestControl control = new ContentSyncRequestControl(ContentSyncRequestMode.REFRESH_AND_PERSIST);
//added control to request
searchRequest.addControl(control);
final SearchResult searchResult = ldapConnection.search(searchRequest);
java.util.List<SearchResultEntry> entries = searchResult
.getSearchEntries();
int count = 0;
for (SearchResultEntry entry : entries) {
System.out.println(entry.getAttributes());
++count;
}
System.out.println("Press 0 for exit");
choice = sc.nextInt();
if (choice == 0) {
System.exit(0);
}
}
} catch (LDAPSearchException e) {
e.printStackTrace();
} catch (LDAPException e) {
e.printStackTrace();
}
but this shows me all entries instate of modified entries.
also when I go through ContentSyncRequestControl
class API documentation then I found following things to keep in mind.
but I dont know how I can set this following things
1] The associated search request should have a SearchResultListener so that entries will be made available as soon as they are returned rather than having to wait for the search to complete and/or consuming a large amount of memory by storing the entries in a list that is only made available when the search completes.
2] Entries and references returned from the search should include the ContentSyncStateControl with the associated entryUUID and potentially a cookie with an updated sync session state. You should call getControl(ContentSyncStateControl.SYNC_STATE_OID) on the search result entries and references in order to retrieve the control with the sync state information.
3] If the search does complete, then the SearchResult may include a ContentSyncDoneControl with updated sync state information. You should call getResponseControl(ContentSyncDoneControl.SYNC_DONE_OID) to retrieve the control with the sync state information.
can any one help me on this ? Thanks...
EDIT
after adding the control I am still getting the all entries instate of modified entries.
right now I am using
ContentSyncRequestControl(ContentSyncRequestMode mode)
constructor so how can I use this form Of constructor can some one help me
ContentSyncRequestControl(boolean isCritical, ContentSyncRequestMode mode, ASN1OctetString cookie, boolean reloadHint)
when I am using ContentSyncRequestMode.REFRESH_ONLY
it gives me all entries but when I use ContentSyncRequestMode.REFRESH_AND_PERSIST
mode the it goes in infinite loop.
so can some one help me on this...?