int sync_send_entry_from_changelog(Slapi_PBlock *pb,int chg_req, char *uniqueid) { Slapi_Entry *db_entry = NULL; int chg_type = LDAP_SYNC_ADD; int rv; Slapi_PBlock *search_pb = NULL; Slapi_Entry **entries = NULL; char *origbase; char *filter = slapi_ch_smprintf("(nsuniqueid=%s)",uniqueid); slapi_pblock_get( pb, SLAPI_ORIGINAL_TARGET_DN, &origbase ); search_pb = slapi_pblock_new(); slapi_search_internal_set_pb(search_pb, origbase, LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL, plugin_get_default_component_id(), 0); slapi_search_internal_pb(search_pb); slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &rv); if ( rv == LDAP_SUCCESS) { slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); if (entries) db_entry = *entries; /* there can only be one */ } if (db_entry && sync_is_entry_in_scope(pb, db_entry)) { LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof (LDAPControl *)); sync_create_state_control(db_entry, &ctrl[0], chg_type, NULL); slapi_send_ldap_search_entry (pb, db_entry, ctrl, NULL, 0); ldap_controls_free(ctrl); } slapi_free_search_results_internal(search_pb); slapi_pblock_destroy(search_pb); slapi_ch_free((void **)&filter); return (0); }
Slapi_PBlock * slapi_rename_internal(const char *iodn, const char *inewrdn, const char *inewsuperior, int deloldrdn, LDAPControl **controls, int dummy) { Slapi_PBlock pb; Slapi_PBlock *result_pb = NULL; int opresult= 0; Slapi_DN sdn; Slapi_DN newsuperiorsdn; pblock_init (&pb); slapi_sdn_init_dn_byref(&sdn, iodn); slapi_sdn_init_dn_byref(&newsuperiorsdn, inewsuperior); slapi_rename_internal_set_pb_ext(&pb, &sdn, inewrdn, &newsuperiorsdn, deloldrdn, controls, NULL, plugin_get_default_component_id(), 0); rename_internal_pb (&pb); result_pb = slapi_pblock_new(); if (result_pb) { slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); } slapi_sdn_done(&sdn); slapi_sdn_done(&newsuperiorsdn); pblock_done(&pb); return result_pb; }
/** * Get a particular entry */ static Slapi_Entry * getConfigEntry( const char *dn, Slapi_Entry **e2 ) { Slapi_DN sdn; slapi_sdn_init_dn_byref( &sdn, dn ); slapi_search_internal_get_entry( &sdn, NULL, e2, plugin_get_default_component_id()); slapi_sdn_done( &sdn ); return *e2; }
static Slapi_Entry * getConfigEntry( Slapi_Entry **e ) { Slapi_DN sdn; /* SNMP_CONFIG_DN: no need to be normalized */ slapi_sdn_init_normdn_byref( &sdn, SNMP_CONFIG_DN ); slapi_search_internal_get_entry( &sdn, NULL, e, plugin_get_default_component_id()); slapi_sdn_done( &sdn ); return *e; }
int sync_refresh_update_content(Slapi_PBlock *pb, Sync_Cookie *client_cookie, Sync_Cookie *server_cookie) { Slapi_PBlock *seq_pb; char *filter; Sync_CallBackData cb_data; int rc; int chg_count = server_cookie->cookie_change_info - client_cookie->cookie_change_info + 1; cb_data.cb_updates = (Sync_UpdateNode *)slapi_ch_calloc(chg_count, sizeof(Sync_UpdateNode)); seq_pb = slapi_pblock_new(); slapi_pblock_init(seq_pb); cb_data.orig_pb = pb; cb_data.change_start = client_cookie->cookie_change_info; filter = slapi_ch_smprintf("(&(changenumber>=%lu)(changenumber<=%lu))", client_cookie->cookie_change_info, server_cookie->cookie_change_info); slapi_search_internal_set_pb( seq_pb, CL_SRCH_BASE, LDAP_SCOPE_ONE, filter, NULL, 0, NULL, NULL, plugin_get_default_component_id(), 0); rc = slapi_search_internal_callback_pb ( seq_pb, &cb_data, NULL, sync_read_entry_from_changelog, NULL); slapi_pblock_destroy(seq_pb); /* Now send the deleted entries in a sync info message * and the modified entries as single entries */ sync_send_deleted_entries(pb, cb_data.cb_updates, chg_count, server_cookie); sync_send_modified_entries(pb, cb_data.cb_updates, chg_count); sync_free_update_nodes(&cb_data.cb_updates, chg_count); slapi_ch_free((void **)&filter); return (rc); }
/* This function is used to issue internal add operation This is an old style API. Its use is discoraged because it is not extendable and because it does not allow to check whether plugin has right to access part of the tree it is trying to modify. Use slapi_add_internal_pb instead Beware: The entry is consumed. */ Slapi_PBlock * slapi_add_entry_internal(Slapi_Entry *e, LDAPControl **controls, int dummy) { Slapi_PBlock pb; Slapi_PBlock *result_pb = NULL; int opresult; pblock_init(&pb); slapi_add_entry_internal_set_pb (&pb, e, controls, plugin_get_default_component_id(), 0); add_internal_pb (&pb); result_pb = slapi_pblock_new(); if (result_pb) { slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); } pblock_done(&pb); return result_pb; }
/* This function is used to issue internal delete operation This is an old style API. Its use is discoraged because it is not extendable and because it does not allow to check whether plugin has right to access part of the tree it is trying to modify. Use slapi_delete_internal_pb instead */ Slapi_PBlock * slapi_delete_internal(const char *idn, LDAPControl **controls, int dummy) { Slapi_PBlock pb; Slapi_PBlock *result_pb; int opresult; pblock_init (&pb); slapi_delete_internal_set_pb (&pb, idn, controls, NULL, plugin_get_default_component_id(), 0); delete_internal_pb (&pb); result_pb = slapi_pblock_new(); if (result_pb) { slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); } pblock_done(&pb); return result_pb; }