LDAP_SYNC(3) | Library Functions Manual | LDAP_SYNC(3) |
ldap_sync_init, ldap_sync_init_refresh_only, ldap_sync_init_refresh_and_persist, ldap_sync_poll - LDAP sync routines
OpenLDAP LDAP (libldap, -lldap)
#include <ldap.h>
int ldap_sync_init(ldap_sync_t *ls, int mode);
int ldap_sync_init_refresh_only(ldap_sync_t *ls);
int ldap_sync_init_refresh_and_persist(ldap_sync_t *ls);
int ldap_sync_poll(ldap_sync_t *ls);
ldap_sync_t * ldap_sync_initialize(ldap_sync_t *ls);
void ldap_sync_destroy(ldap_sync_t *ls, int freeit);
typedef int (*ldap_sync_search_entry_f)(ldap_sync_t *ls,
LDAPMessage *msg, struct berval *entryUUID, ldap_sync_refresh_t phase);
typedef int (*ldap_sync_search_reference_f)(ldap_sync_t *ls,
LDAPMessage *msg);
typedef int (*ldap_sync_intermediate_f)(ldap_sync_t *ls,
LDAPMessage *msg, BerVarray syncUUIDs, ldap_sync_refresh_t phase);
typedef int (*ldap_sync_search_result_f)(ldap_sync_t *ls,
LDAPMessage *msg, int refreshDeletes);
These routines provide an interface to the LDAP Content Synchronization operation (RFC 4533). They require an ldap_sync_t structure to be set up with parameters required for various phases of the operation; this includes setting some handlers for special events. All handlers take a pointer to the ldap_sync_t structure as the first argument, and a pointer to the LDAPMessage structure as received from the server by the client library, plus, occasionally, other specific arguments.
The members of the ldap_sync_t structure are:
A ldap_sync_t structure is initialized by calling ldap_sync_initialize(3). This simply clears out the contents of an already existing ldap_sync_t structure, and sets appropriate values for some members. After that, the caller is responsible for setting up the connection (member ls_ld), eventually setting up transport security (TLS), for binding and any other initialization. The caller must also fill all the documented search-related fields of the ldap_sync_t structure.
At the end of a session, the structure can be cleaned up by calling ldap_sync_destroy(3), which takes care of freeing all data assuming it was allocated by ldap_mem*(3) routines. Otherwise, the caller should take care of destroying and zeroing out the documented search-related fields, and call ldap_sync_destroy(3) to free undocumented members set by the API.
The refreshOnly functionality is obtained by periodically calling ldap_sync_init(3) with mode set to LDAP_SYNC_REFRESH_ONLY, or, which is equivalent, by directly calling ldap_sync_init_refresh_only(3). The state of the search, and the consistency of the search parameters, is preserved across calls by passing the ldap_sync_t structure as left by the previous call.
The refreshAndPersist functionality is obtained by calling ldap_sync_init(3) with mode set to LDAP_SYNC_REFRESH_AND_PERSIST, or, which is equivalent, by directly calling ldap_sync_init_refresh_and_persist(3) and, after a successful return, by repeatedly polling with ldap_sync_poll(3) according to the desired pattern.
A client may insert a call to ldap_sync_poll(3) into an external loop to check if any modification was returned; in this case, it might be appropriate to set ls_timeout to 0, or to set it to a finite, small value. Otherwise, if the client's main purpose consists in waiting for responses, a timeout of -1 is most suitable, so that the function only returns after some data has been received and handled.
All routines return any LDAP error resulting from a lower-level error in the API calls they are based on, or LDAP_SUCCESS in case of success. ldap_sync_poll(3) may return LDAP_SYNC_REFRESH_REQUIRED if a full refresh is requested by the server. In this case, it is appropriate to call ldap_sync_init(3) again, passing the same ldap_sync_t structure as resulted from any previous call.
ldap(3), ldap_search_ext(3), ldap_result(3); RFC 4533 (http://www.rfc-editor.org),
Designed and implemented by Pierangelo Masarati, based on RFC 4533 and loosely inspired by syncrepl code in slapd(8).
Initially developed by SysNet s.n.c. OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan LDAP 3.3 Release.
2022/07/14 | OpenLDAP 2.5.13+dfsg-5 |