I'm wanting to write a client in C/C++ that does a "refresh and persist" sync search on an entry.    I'm looking at the ldap_sync(3) man page and that looks like it would do most things that I need.    I can't find any example code that is using that interface, so if somebody could point me to any that does, I'd really appreciate it.

I do understand that I need to initialize the API with the ldap_sync_initialize() to get an ldap_sync_t structure.    The members of the structure seem straightforward enough but I don't understand how I connect my ldap connection (LDAP*) to this API.    How does that work??

Also, I don't understand how the different function typedefs work.    I mean that I understand that I need four functions:

ldap_sync_search_entry_f my_search_entry(...);
ldap_sync_search_reference_function_f my_search_reference(...);
ldap_sync_search_intermediate_f my_search_intermediate(...);
ldap_sync_search_result_f my_search_result(...);

But how does the ldap_sync(3) API become aware of those functions?   

Or... is there an easier way to do what I want?    Looks like the ldapsearch command line tool just adds a control to the search (-E sync=rp) and handles the resulting messages as necessary.   Should I be trying to do that instead of using ldap_sync(3)?


Thanks,
--
Frank