4 Copyright (C) Simo Sorce 2004-2008
5 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
6 Copyright (C) Andrew Tridgell 2005
7 Copyright (C) Stefan Metzmacher <metze@samba.org> 2007
9 ** NOTE! The following LGPL license applies to the ldb
10 ** library. This does NOT imply that all of Samba is released
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, see <http://www.gnu.org/licenses/>.
30 * Component: ldb repl_meta_data module
32 * Description: - add a unique objectGUID onto every new record,
33 * - handle whenCreated, whenChanged timestamps
34 * - handle uSNCreated, uSNChanged numbers
35 * - handle replPropertyMetaData attribute
38 * Author: Stefan Metzmacher
42 #include "lib/ldb/include/ldb.h"
43 #include "lib/ldb/include/ldb_errors.h"
44 #include "lib/ldb/include/ldb_private.h"
45 #include "dsdb/samdb/samdb.h"
46 #include "dsdb/common/flags.h"
47 #include "librpc/gen_ndr/ndr_misc.h"
48 #include "librpc/gen_ndr/ndr_drsuapi.h"
49 #include "librpc/gen_ndr/ndr_drsblobs.h"
50 #include "param/param.h"
52 struct replmd_replicated_request
{
53 struct ldb_module
*module
;
54 struct ldb_request
*req
;
56 const struct dsdb_schema
*schema
;
58 struct dsdb_extended_replicated_objects
*objs
;
60 /* the controls we pass down */
61 struct ldb_control
**controls
;
63 uint32_t index_current
;
65 struct ldb_message
*search_msg
;
68 static struct replmd_replicated_request
*replmd_ctx_init(struct ldb_module
*module
,
69 struct ldb_request
*req
)
71 struct replmd_replicated_request
*ac
;
73 ac
= talloc_zero(req
, struct replmd_replicated_request
);
85 add a time element to a record
87 static int add_time_element(struct ldb_message
*msg
, const char *attr
, time_t t
)
89 struct ldb_message_element
*el
;
92 if (ldb_msg_find_element(msg
, attr
) != NULL
) {
96 s
= ldb_timestring(msg
, t
);
98 return LDB_ERR_OPERATIONS_ERROR
;
101 if (ldb_msg_add_string(msg
, attr
, s
) != 0) {
102 return LDB_ERR_OPERATIONS_ERROR
;
105 el
= ldb_msg_find_element(msg
, attr
);
106 /* always set as replace. This works because on add ops, the flag
108 el
->flags
= LDB_FLAG_MOD_REPLACE
;
114 add a uint64_t element to a record
116 static int add_uint64_element(struct ldb_message
*msg
, const char *attr
, uint64_t v
)
118 struct ldb_message_element
*el
;
120 if (ldb_msg_find_element(msg
, attr
) != NULL
) {
124 if (ldb_msg_add_fmt(msg
, attr
, "%llu", (unsigned long long)v
) != 0) {
125 return LDB_ERR_OPERATIONS_ERROR
;
128 el
= ldb_msg_find_element(msg
, attr
);
129 /* always set as replace. This works because on add ops, the flag
131 el
->flags
= LDB_FLAG_MOD_REPLACE
;
136 static int replmd_replPropertyMetaData1_attid_sort(const struct replPropertyMetaData1
*m1
,
137 const struct replPropertyMetaData1
*m2
,
138 const uint32_t *rdn_attid
)
140 if (m1
->attid
== m2
->attid
) {
145 * the rdn attribute should be at the end!
146 * so we need to return a value greater than zero
147 * which means m1 is greater than m2
149 if (m1
->attid
== *rdn_attid
) {
154 * the rdn attribute should be at the end!
155 * so we need to return a value less than zero
156 * which means m2 is greater than m1
158 if (m2
->attid
== *rdn_attid
) {
162 return m1
->attid
- m2
->attid
;
165 static void replmd_replPropertyMetaDataCtr1_sort(struct replPropertyMetaDataCtr1
*ctr1
,
166 const uint32_t *rdn_attid
)
168 ldb_qsort(ctr1
->array
, ctr1
->count
, sizeof(struct replPropertyMetaData1
),
169 discard_const_p(void, rdn_attid
), (ldb_qsort_cmp_fn_t
)replmd_replPropertyMetaData1_attid_sort
);
172 static int replmd_ldb_message_element_attid_sort(const struct ldb_message_element
*e1
,
173 const struct ldb_message_element
*e2
,
174 const struct dsdb_schema
*schema
)
176 const struct dsdb_attribute
*a1
;
177 const struct dsdb_attribute
*a2
;
180 * TODO: make this faster by caching the dsdb_attribute pointer
181 * on the ldb_messag_element
184 a1
= dsdb_attribute_by_lDAPDisplayName(schema
, e1
->name
);
185 a2
= dsdb_attribute_by_lDAPDisplayName(schema
, e2
->name
);
188 * TODO: remove this check, we should rely on e1 and e2 having valid attribute names
192 return strcasecmp(e1
->name
, e2
->name
);
195 return a1
->attributeID_id
- a2
->attributeID_id
;
198 static void replmd_ldb_message_sort(struct ldb_message
*msg
,
199 const struct dsdb_schema
*schema
)
201 ldb_qsort(msg
->elements
, msg
->num_elements
, sizeof(struct ldb_message_element
),
202 discard_const_p(void, schema
), (ldb_qsort_cmp_fn_t
)replmd_ldb_message_element_attid_sort
);
205 static int replmd_op_callback(struct ldb_request
*req
, struct ldb_reply
*ares
)
207 struct replmd_replicated_request
*ac
;
209 ac
= talloc_get_type(req
->context
, struct replmd_replicated_request
);
212 return ldb_module_done(ac
->req
, NULL
, NULL
,
213 LDB_ERR_OPERATIONS_ERROR
);
215 if (ares
->error
!= LDB_SUCCESS
) {
216 return ldb_module_done(ac
->req
, ares
->controls
,
217 ares
->response
, ares
->error
);
220 if (ares
->type
!= LDB_REPLY_DONE
) {
221 ldb_set_errstring(ac
->module
->ldb
,
222 "invalid ldb_reply_type in callback");
224 return ldb_module_done(ac
->req
, NULL
, NULL
,
225 LDB_ERR_OPERATIONS_ERROR
);
228 return ldb_module_done(ac
->req
, ares
->controls
,
229 ares
->response
, LDB_SUCCESS
);
232 static int replmd_add(struct ldb_module
*module
, struct ldb_request
*req
)
234 struct replmd_replicated_request
*ac
;
235 const struct dsdb_schema
*schema
;
236 enum ndr_err_code ndr_err
;
237 struct ldb_request
*down_req
;
238 struct ldb_message
*msg
;
239 const struct dsdb_attribute
*rdn_attr
= NULL
;
241 struct ldb_val guid_value
;
242 struct replPropertyMetaDataBlob nmd
;
243 struct ldb_val nmd_value
;
245 const struct GUID
*our_invocation_id
;
246 time_t t
= time(NULL
);
252 /* do not manipulate our control entries */
253 if (ldb_dn_is_special(req
->op
.add
.message
->dn
)) {
254 return ldb_next_request(module
, req
);
257 ldb_debug(module
->ldb
, LDB_DEBUG_TRACE
, "replmd_add\n");
259 schema
= dsdb_get_schema(module
->ldb
);
261 ldb_debug_set(module
->ldb
, LDB_DEBUG_FATAL
,
262 "replmd_modify: no dsdb_schema loaded");
263 return LDB_ERR_CONSTRAINT_VIOLATION
;
266 ac
= replmd_ctx_init(module
, req
);
268 return LDB_ERR_OPERATIONS_ERROR
;
273 if (ldb_msg_find_element(req
->op
.add
.message
, "objectGUID")) {
274 ldb_debug_set(module
->ldb
, LDB_DEBUG_ERROR
,
275 "replmd_add: it's not allowed to add an object with objectGUID\n");
276 return LDB_ERR_UNWILLING_TO_PERFORM
;
279 /* Get a sequence number from the backend */
280 ret
= ldb_sequence_number(module
->ldb
, LDB_SEQ_NEXT
, &seq_num
);
281 if (ret
!= LDB_SUCCESS
) {
286 guid
= GUID_random();
288 /* get our invicationId */
289 our_invocation_id
= samdb_ntds_invocation_id(module
->ldb
);
290 if (!our_invocation_id
) {
291 ldb_debug_set(module
->ldb
, LDB_DEBUG_ERROR
,
292 "replmd_add: unable to find invocationId\n");
293 return LDB_ERR_OPERATIONS_ERROR
;
296 /* we have to copy the message as the caller might have it as a const */
297 msg
= ldb_msg_copy_shallow(ac
, req
->op
.add
.message
);
299 ldb_oom(module
->ldb
);
300 return LDB_ERR_OPERATIONS_ERROR
;
303 /* generated times */
304 unix_to_nt_time(&now
, t
);
305 time_str
= ldb_timestring(msg
, t
);
307 return LDB_ERR_OPERATIONS_ERROR
;
311 * remove autogenerated attributes
313 ldb_msg_remove_attr(msg
, "whenCreated");
314 ldb_msg_remove_attr(msg
, "whenChanged");
315 ldb_msg_remove_attr(msg
, "uSNCreated");
316 ldb_msg_remove_attr(msg
, "uSNChanged");
317 ldb_msg_remove_attr(msg
, "replPropertyMetaData");
320 * readd replicated attributes
322 ret
= ldb_msg_add_string(msg
, "whenCreated", time_str
);
323 if (ret
!= LDB_SUCCESS
) {
324 ldb_oom(module
->ldb
);
325 return LDB_ERR_OPERATIONS_ERROR
;
328 /* build the replication meta_data */
331 nmd
.ctr
.ctr1
.count
= msg
->num_elements
;
332 nmd
.ctr
.ctr1
.array
= talloc_array(msg
,
333 struct replPropertyMetaData1
,
335 if (!nmd
.ctr
.ctr1
.array
) {
336 ldb_oom(module
->ldb
);
337 return LDB_ERR_OPERATIONS_ERROR
;
340 for (i
=0; i
< msg
->num_elements
; i
++) {
341 struct ldb_message_element
*e
= &msg
->elements
[i
];
342 struct replPropertyMetaData1
*m
= &nmd
.ctr
.ctr1
.array
[ni
];
343 const struct dsdb_attribute
*sa
;
345 if (e
->name
[0] == '@') continue;
347 sa
= dsdb_attribute_by_lDAPDisplayName(schema
, e
->name
);
349 ldb_debug_set(module
->ldb
, LDB_DEBUG_ERROR
,
350 "replmd_add: attribute '%s' not defined in schema\n",
352 return LDB_ERR_NO_SUCH_ATTRIBUTE
;
355 if ((sa
->systemFlags
& 0x00000001) || (sa
->systemFlags
& 0x00000004)) {
356 /* if the attribute is not replicated (0x00000001)
357 * or constructed (0x00000004) it has no metadata
362 m
->attid
= sa
->attributeID_id
;
364 m
->originating_change_time
= now
;
365 m
->originating_invocation_id
= *our_invocation_id
;
366 m
->originating_usn
= seq_num
;
367 m
->local_usn
= seq_num
;
370 if (ldb_attr_cmp(e
->name
, ldb_dn_get_rdn_name(msg
->dn
))) {
375 /* fix meta data count */
376 nmd
.ctr
.ctr1
.count
= ni
;
379 * sort meta data array, and move the rdn attribute entry to the end
381 replmd_replPropertyMetaDataCtr1_sort(&nmd
.ctr
.ctr1
, &rdn_attr
->attributeID_id
);
383 /* generated NDR encoded values */
384 ndr_err
= ndr_push_struct_blob(&guid_value
, msg
,
387 (ndr_push_flags_fn_t
)ndr_push_GUID
);
388 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
389 ldb_oom(module
->ldb
);
390 return LDB_ERR_OPERATIONS_ERROR
;
392 ndr_err
= ndr_push_struct_blob(&nmd_value
, msg
,
393 lp_iconv_convenience(ldb_get_opaque(module
->ldb
, "loadparm")),
395 (ndr_push_flags_fn_t
)ndr_push_replPropertyMetaDataBlob
);
396 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
397 ldb_oom(module
->ldb
);
398 return LDB_ERR_OPERATIONS_ERROR
;
402 * add the autogenerated values
404 ret
= ldb_msg_add_value(msg
, "objectGUID", &guid_value
, NULL
);
405 if (ret
!= LDB_SUCCESS
) {
406 ldb_oom(module
->ldb
);
407 return LDB_ERR_OPERATIONS_ERROR
;
409 ret
= ldb_msg_add_string(msg
, "whenChanged", time_str
);
410 if (ret
!= LDB_SUCCESS
) {
411 ldb_oom(module
->ldb
);
412 return LDB_ERR_OPERATIONS_ERROR
;
414 ret
= samdb_msg_add_uint64(module
->ldb
, msg
, msg
, "uSNCreated", seq_num
);
415 if (ret
!= LDB_SUCCESS
) {
416 ldb_oom(module
->ldb
);
417 return LDB_ERR_OPERATIONS_ERROR
;
419 ret
= samdb_msg_add_uint64(module
->ldb
, msg
, msg
, "uSNChanged", seq_num
);
420 if (ret
!= LDB_SUCCESS
) {
421 ldb_oom(module
->ldb
);
422 return LDB_ERR_OPERATIONS_ERROR
;
424 ret
= ldb_msg_add_value(msg
, "replPropertyMetaData", &nmd_value
, NULL
);
425 if (ret
!= LDB_SUCCESS
) {
426 ldb_oom(module
->ldb
);
427 return LDB_ERR_OPERATIONS_ERROR
;
431 * sort the attributes by attid before storing the object
433 replmd_ldb_message_sort(msg
, schema
);
435 ret
= ldb_build_add_req(&down_req
, module
->ldb
, ac
,
438 ac
, replmd_op_callback
,
440 if (ret
!= LDB_SUCCESS
) {
444 /* go on with the call chain */
445 return ldb_next_request(module
, down_req
);
448 static int replmd_modify(struct ldb_module
*module
, struct ldb_request
*req
)
450 struct replmd_replicated_request
*ac
;
451 const struct dsdb_schema
*schema
;
452 struct ldb_request
*down_req
;
453 struct ldb_message
*msg
;
455 time_t t
= time(NULL
);
458 /* do not manipulate our control entries */
459 if (ldb_dn_is_special(req
->op
.mod
.message
->dn
)) {
460 return ldb_next_request(module
, req
);
463 ldb_debug(module
->ldb
, LDB_DEBUG_TRACE
, "replmd_modify\n");
465 schema
= dsdb_get_schema(module
->ldb
);
467 ldb_debug_set(module
->ldb
, LDB_DEBUG_FATAL
,
468 "replmd_modify: no dsdb_schema loaded");
469 return LDB_ERR_CONSTRAINT_VIOLATION
;
472 ac
= replmd_ctx_init(module
, req
);
474 return LDB_ERR_OPERATIONS_ERROR
;
479 /* we have to copy the message as the caller might have it as a const */
480 msg
= ldb_msg_copy_shallow(ac
, req
->op
.mod
.message
);
483 return LDB_ERR_OPERATIONS_ERROR
;
487 * - get the whole old object
488 * - if the old object doesn't exist report an error
489 * - give an error when a readonly attribute should
491 * - merge the changed into the old object
492 * if the caller set values to the same value
493 * ignore the attribute, return success when no
494 * attribute was changed
495 * - calculate the new replPropertyMetaData attribute
498 if (add_time_element(msg
, "whenChanged", t
) != 0) {
500 return LDB_ERR_OPERATIONS_ERROR
;
503 /* Get a sequence number from the backend */
504 ret
= ldb_sequence_number(module
->ldb
, LDB_SEQ_NEXT
, &seq_num
);
505 if (ret
== LDB_SUCCESS
) {
506 if (add_uint64_element(msg
, "uSNChanged", seq_num
) != 0) {
508 return LDB_ERR_OPERATIONS_ERROR
;
513 * - sort the attributes by attid with replmd_ldb_message_sort()
514 * - replace the old object with the newly constructed one
517 ret
= ldb_build_mod_req(&down_req
, module
->ldb
, ac
,
520 ac
, replmd_op_callback
,
522 if (ret
!= LDB_SUCCESS
) {
525 talloc_steal(down_req
, msg
);
527 /* go on with the call chain */
528 return ldb_next_request(module
, down_req
);
531 static int replmd_replicated_request_error(struct replmd_replicated_request
*ar
, int ret
)
536 static int replmd_replicated_request_werror(struct replmd_replicated_request
*ar
, WERROR status
)
538 int ret
= LDB_ERR_OTHER
;
539 /* TODO: do some error mapping */
543 static int replmd_replicated_apply_next(struct replmd_replicated_request
*ar
);
545 static int replmd_replicated_apply_add_callback(struct ldb_request
*req
,
546 struct ldb_reply
*ares
)
548 struct replmd_replicated_request
*ar
= talloc_get_type(req
->context
,
549 struct replmd_replicated_request
);
554 return ldb_module_done(ar
->req
, NULL
, NULL
,
555 LDB_ERR_OPERATIONS_ERROR
);
557 if (ares
->error
!= LDB_SUCCESS
) {
558 return ldb_module_done(ar
->req
, ares
->controls
,
559 ares
->response
, ares
->error
);
562 if (ares
->type
!= LDB_REPLY_DONE
) {
563 ldb_set_errstring(ar
->module
->ldb
, "Invalid reply type\n!");
564 return ldb_module_done(ar
->req
, NULL
, NULL
,
565 LDB_ERR_OPERATIONS_ERROR
);
571 ret
= replmd_replicated_apply_next(ar
);
572 if (ret
!= LDB_SUCCESS
) {
573 return ldb_module_done(ar
->req
, NULL
, NULL
, ret
);
579 static int replmd_replicated_apply_add(struct replmd_replicated_request
*ar
)
581 struct ldb_request
*change_req
;
582 enum ndr_err_code ndr_err
;
583 struct ldb_message
*msg
;
584 struct replPropertyMetaDataBlob
*md
;
585 struct ldb_val md_value
;
591 * TODO: check if the parent object exist
595 * TODO: handle the conflict case where an object with the
599 msg
= ar
->objs
->objects
[ar
->index_current
].msg
;
600 md
= ar
->objs
->objects
[ar
->index_current
].meta_data
;
602 ret
= ldb_sequence_number(ar
->module
->ldb
, LDB_SEQ_NEXT
, &seq_num
);
603 if (ret
!= LDB_SUCCESS
) {
604 return replmd_replicated_request_error(ar
, ret
);
607 ret
= ldb_msg_add_value(msg
, "objectGUID", &ar
->objs
->objects
[ar
->index_current
].guid_value
, NULL
);
608 if (ret
!= LDB_SUCCESS
) {
609 return replmd_replicated_request_error(ar
, ret
);
612 ret
= ldb_msg_add_string(msg
, "whenChanged", ar
->objs
->objects
[ar
->index_current
].when_changed
);
613 if (ret
!= LDB_SUCCESS
) {
614 return replmd_replicated_request_error(ar
, ret
);
617 ret
= samdb_msg_add_uint64(ar
->module
->ldb
, msg
, msg
, "uSNCreated", seq_num
);
618 if (ret
!= LDB_SUCCESS
) {
619 return replmd_replicated_request_error(ar
, ret
);
622 ret
= samdb_msg_add_uint64(ar
->module
->ldb
, msg
, msg
, "uSNChanged", seq_num
);
623 if (ret
!= LDB_SUCCESS
) {
624 return replmd_replicated_request_error(ar
, ret
);
628 * the meta data array is already sorted by the caller
630 for (i
=0; i
< md
->ctr
.ctr1
.count
; i
++) {
631 md
->ctr
.ctr1
.array
[i
].local_usn
= seq_num
;
633 ndr_err
= ndr_push_struct_blob(&md_value
, msg
,
634 lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")),
636 (ndr_push_flags_fn_t
)ndr_push_replPropertyMetaDataBlob
);
637 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
638 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
639 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
641 ret
= ldb_msg_add_value(msg
, "replPropertyMetaData", &md_value
, NULL
);
642 if (ret
!= LDB_SUCCESS
) {
643 return replmd_replicated_request_error(ar
, ret
);
646 replmd_ldb_message_sort(msg
, ar
->schema
);
648 ret
= ldb_build_add_req(&change_req
,
654 replmd_replicated_apply_add_callback
,
656 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
658 return ldb_next_request(ar
->module
, change_req
);
661 static int replmd_replPropertyMetaData1_conflict_compare(struct replPropertyMetaData1
*m1
,
662 struct replPropertyMetaData1
*m2
)
666 if (m1
->version
!= m2
->version
) {
667 return m1
->version
- m2
->version
;
670 if (m1
->originating_change_time
!= m2
->originating_change_time
) {
671 return m1
->originating_change_time
- m2
->originating_change_time
;
674 ret
= GUID_compare(&m1
->originating_invocation_id
, &m2
->originating_invocation_id
);
679 return m1
->originating_usn
- m2
->originating_usn
;
682 static int replmd_replicated_apply_merge_callback(struct ldb_request
*req
,
683 struct ldb_reply
*ares
)
685 struct replmd_replicated_request
*ar
= talloc_get_type(req
->context
,
686 struct replmd_replicated_request
);
690 return ldb_module_done(ar
->req
, NULL
, NULL
,
691 LDB_ERR_OPERATIONS_ERROR
);
693 if (ares
->error
!= LDB_SUCCESS
) {
694 return ldb_module_done(ar
->req
, ares
->controls
,
695 ares
->response
, ares
->error
);
698 if (ares
->type
!= LDB_REPLY_DONE
) {
699 ldb_set_errstring(ar
->module
->ldb
, "Invalid reply type\n!");
700 return ldb_module_done(ar
->req
, NULL
, NULL
,
701 LDB_ERR_OPERATIONS_ERROR
);
707 ret
= replmd_replicated_apply_next(ar
);
708 if (ret
!= LDB_SUCCESS
) {
709 return ldb_module_done(ar
->req
, NULL
, NULL
, ret
);
715 static int replmd_replicated_apply_merge(struct replmd_replicated_request
*ar
)
717 struct ldb_request
*change_req
;
718 enum ndr_err_code ndr_err
;
719 struct ldb_message
*msg
;
720 struct replPropertyMetaDataBlob
*rmd
;
721 struct replPropertyMetaDataBlob omd
;
722 const struct ldb_val
*omd_value
;
723 struct replPropertyMetaDataBlob nmd
;
724 struct ldb_val nmd_value
;
726 uint32_t removed_attrs
= 0;
730 msg
= ar
->objs
->objects
[ar
->index_current
].msg
;
731 rmd
= ar
->objs
->objects
[ar
->index_current
].meta_data
;
736 * TODO: add rename conflict handling
738 if (ldb_dn_compare(msg
->dn
, ar
->search_msg
->dn
) != 0) {
739 ldb_debug_set(ar
->module
->ldb
, LDB_DEBUG_FATAL
, "replmd_replicated_apply_merge[%u]: rename not supported",
741 ldb_debug(ar
->module
->ldb
, LDB_DEBUG_FATAL
, "%s => %s\n",
742 ldb_dn_get_linearized(ar
->search_msg
->dn
),
743 ldb_dn_get_linearized(msg
->dn
));
744 return replmd_replicated_request_werror(ar
, WERR_NOT_SUPPORTED
);
747 ret
= ldb_sequence_number(ar
->module
->ldb
, LDB_SEQ_NEXT
, &seq_num
);
748 if (ret
!= LDB_SUCCESS
) {
749 return replmd_replicated_request_error(ar
, ret
);
752 /* find existing meta data */
753 omd_value
= ldb_msg_find_ldb_val(ar
->search_msg
, "replPropertyMetaData");
755 ndr_err
= ndr_pull_struct_blob(omd_value
, ar
,
756 lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")), &omd
,
757 (ndr_pull_flags_fn_t
)ndr_pull_replPropertyMetaDataBlob
);
758 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
759 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
760 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
763 if (omd
.version
!= 1) {
764 return replmd_replicated_request_werror(ar
, WERR_DS_DRA_INTERNAL_ERROR
);
770 nmd
.ctr
.ctr1
.count
= omd
.ctr
.ctr1
.count
+ rmd
->ctr
.ctr1
.count
;
771 nmd
.ctr
.ctr1
.array
= talloc_array(ar
,
772 struct replPropertyMetaData1
,
774 if (!nmd
.ctr
.ctr1
.array
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
776 /* first copy the old meta data */
777 for (i
=0; i
< omd
.ctr
.ctr1
.count
; i
++) {
778 nmd
.ctr
.ctr1
.array
[ni
] = omd
.ctr
.ctr1
.array
[i
];
782 /* now merge in the new meta data */
783 for (i
=0; i
< rmd
->ctr
.ctr1
.count
; i
++) {
786 rmd
->ctr
.ctr1
.array
[i
].local_usn
= seq_num
;
788 for (j
=0; j
< ni
; j
++) {
791 if (rmd
->ctr
.ctr1
.array
[i
].attid
!= nmd
.ctr
.ctr1
.array
[j
].attid
) {
795 cmp
= replmd_replPropertyMetaData1_conflict_compare(&rmd
->ctr
.ctr1
.array
[i
],
796 &nmd
.ctr
.ctr1
.array
[j
]);
798 /* replace the entry */
799 nmd
.ctr
.ctr1
.array
[j
] = rmd
->ctr
.ctr1
.array
[i
];
804 /* we don't want to apply this change so remove the attribute */
805 ldb_msg_remove_element(msg
, &msg
->elements
[i
-removed_attrs
]);
814 nmd
.ctr
.ctr1
.array
[ni
] = rmd
->ctr
.ctr1
.array
[i
];
819 * finally correct the size of the meta_data array
821 nmd
.ctr
.ctr1
.count
= ni
;
824 * the rdn attribute (the alias for the name attribute),
825 * 'cn' for most objects is the last entry in the meta data array
828 * sort the new meta data array
831 struct replPropertyMetaData1
*rdn_p
;
832 uint32_t rdn_idx
= omd
.ctr
.ctr1
.count
- 1;
834 rdn_p
= &nmd
.ctr
.ctr1
.array
[rdn_idx
];
835 replmd_replPropertyMetaDataCtr1_sort(&nmd
.ctr
.ctr1
, &rdn_p
->attid
);
838 /* create the meta data value */
839 ndr_err
= ndr_push_struct_blob(&nmd_value
, msg
,
840 lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")),
842 (ndr_push_flags_fn_t
)ndr_push_replPropertyMetaDataBlob
);
843 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
844 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
845 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
849 * check if some replicated attributes left, otherwise skip the ldb_modify() call
851 if (msg
->num_elements
== 0) {
852 ldb_debug(ar
->module
->ldb
, LDB_DEBUG_TRACE
, "replmd_replicated_apply_merge[%u]: skip replace\n",
856 return replmd_replicated_apply_next(ar
);
859 ldb_debug(ar
->module
->ldb
, LDB_DEBUG_TRACE
, "replmd_replicated_apply_merge[%u]: replace %u attributes\n",
860 ar
->index_current
, msg
->num_elements
);
863 * when we know that we'll modify the record, add the whenChanged, uSNChanged
864 * and replPopertyMetaData attributes
866 ret
= ldb_msg_add_string(msg
, "whenChanged", ar
->objs
->objects
[ar
->index_current
].when_changed
);
867 if (ret
!= LDB_SUCCESS
) {
868 return replmd_replicated_request_error(ar
, ret
);
870 ret
= samdb_msg_add_uint64(ar
->module
->ldb
, msg
, msg
, "uSNChanged", seq_num
);
871 if (ret
!= LDB_SUCCESS
) {
872 return replmd_replicated_request_error(ar
, ret
);
874 ret
= ldb_msg_add_value(msg
, "replPropertyMetaData", &nmd_value
, NULL
);
875 if (ret
!= LDB_SUCCESS
) {
876 return replmd_replicated_request_error(ar
, ret
);
879 replmd_ldb_message_sort(msg
, ar
->schema
);
881 /* we want to replace the old values */
882 for (i
=0; i
< msg
->num_elements
; i
++) {
883 msg
->elements
[i
].flags
= LDB_FLAG_MOD_REPLACE
;
886 ret
= ldb_build_mod_req(&change_req
,
892 replmd_replicated_apply_merge_callback
,
894 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
896 return ldb_next_request(ar
->module
, change_req
);
899 static int replmd_replicated_apply_search_callback(struct ldb_request
*req
,
900 struct ldb_reply
*ares
)
902 struct replmd_replicated_request
*ar
= talloc_get_type(req
->context
,
903 struct replmd_replicated_request
);
907 return ldb_module_done(ar
->req
, NULL
, NULL
,
908 LDB_ERR_OPERATIONS_ERROR
);
910 if (ares
->error
!= LDB_SUCCESS
&&
911 ares
->error
!= LDB_ERR_NO_SUCH_OBJECT
) {
912 return ldb_module_done(ar
->req
, ares
->controls
,
913 ares
->response
, ares
->error
);
916 switch (ares
->type
) {
917 case LDB_REPLY_ENTRY
:
918 ar
->search_msg
= talloc_steal(ar
, ares
->message
);
921 case LDB_REPLY_REFERRAL
:
922 /* we ignore referrals */
926 if (ar
->search_msg
!= NULL
) {
927 ret
= replmd_replicated_apply_merge(ar
);
929 ret
= replmd_replicated_apply_add(ar
);
931 if (ret
!= LDB_SUCCESS
) {
932 return ldb_module_done(ar
->req
, NULL
, NULL
, ret
);
940 static int replmd_replicated_uptodate_vector(struct replmd_replicated_request
*ar
);
942 static int replmd_replicated_apply_next(struct replmd_replicated_request
*ar
)
947 struct ldb_request
*search_req
;
949 if (ar
->index_current
>= ar
->objs
->num_objects
) {
950 /* done with it, go to the last op */
951 return replmd_replicated_uptodate_vector(ar
);
954 ar
->search_msg
= NULL
;
956 tmp_str
= ldb_binary_encode(ar
, ar
->objs
->objects
[ar
->index_current
].guid_value
);
957 if (!tmp_str
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
959 filter
= talloc_asprintf(ar
, "(objectGUID=%s)", tmp_str
);
960 if (!filter
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
961 talloc_free(tmp_str
);
963 ret
= ldb_build_search_req(&search_req
,
966 ar
->objs
->partition_dn
,
972 replmd_replicated_apply_search_callback
,
974 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
976 return ldb_next_request(ar
->module
, search_req
);
979 static int replmd_replicated_uptodate_modify_callback(struct ldb_request
*req
,
980 struct ldb_reply
*ares
)
982 struct replmd_replicated_request
*ar
= talloc_get_type(req
->context
,
983 struct replmd_replicated_request
);
986 return ldb_module_done(ar
->req
, NULL
, NULL
,
987 LDB_ERR_OPERATIONS_ERROR
);
989 if (ares
->error
!= LDB_SUCCESS
) {
990 return ldb_module_done(ar
->req
, ares
->controls
,
991 ares
->response
, ares
->error
);
994 if (ares
->type
!= LDB_REPLY_DONE
) {
995 ldb_set_errstring(ar
->module
->ldb
, "Invalid reply type\n!");
996 return ldb_module_done(ar
->req
, NULL
, NULL
,
997 LDB_ERR_OPERATIONS_ERROR
);
1002 return ldb_module_done(ar
->req
, NULL
, NULL
, LDB_SUCCESS
);
1005 static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplicaCursor2
*c1
,
1006 const struct drsuapi_DsReplicaCursor2
*c2
)
1008 return GUID_compare(&c1
->source_dsa_invocation_id
, &c2
->source_dsa_invocation_id
);
1011 static int replmd_replicated_uptodate_modify(struct replmd_replicated_request
*ar
)
1013 struct ldb_request
*change_req
;
1014 enum ndr_err_code ndr_err
;
1015 struct ldb_message
*msg
;
1016 struct replUpToDateVectorBlob ouv
;
1017 const struct ldb_val
*ouv_value
;
1018 const struct drsuapi_DsReplicaCursor2CtrEx
*ruv
;
1019 struct replUpToDateVectorBlob nuv
;
1020 struct ldb_val nuv_value
;
1021 struct ldb_message_element
*nuv_el
= NULL
;
1022 const struct GUID
*our_invocation_id
;
1023 struct ldb_message_element
*orf_el
= NULL
;
1024 struct repsFromToBlob nrf
;
1025 struct ldb_val
*nrf_value
= NULL
;
1026 struct ldb_message_element
*nrf_el
= NULL
;
1030 time_t t
= time(NULL
);
1034 ruv
= ar
->objs
->uptodateness_vector
;
1040 unix_to_nt_time(&now
, t
);
1043 * we use the next sequence number for our own highest_usn
1044 * because we will do a modify request and this will increment
1047 ret
= ldb_sequence_number(ar
->module
->ldb
, LDB_SEQ_NEXT
, &seq_num
);
1048 if (ret
!= LDB_SUCCESS
) {
1049 return replmd_replicated_request_error(ar
, ret
);
1053 * first create the new replUpToDateVector
1055 ouv_value
= ldb_msg_find_ldb_val(ar
->search_msg
, "replUpToDateVector");
1057 ndr_err
= ndr_pull_struct_blob(ouv_value
, ar
,
1058 lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")), &ouv
,
1059 (ndr_pull_flags_fn_t
)ndr_pull_replUpToDateVectorBlob
);
1060 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
1061 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
1062 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
1065 if (ouv
.version
!= 2) {
1066 return replmd_replicated_request_werror(ar
, WERR_DS_DRA_INTERNAL_ERROR
);
1071 * the new uptodateness vector will at least
1072 * contain 1 entry, one for the source_dsa
1074 * plus optional values from our old vector and the one from the source_dsa
1076 nuv
.ctr
.ctr2
.count
= 1 + ouv
.ctr
.ctr2
.count
;
1077 if (ruv
) nuv
.ctr
.ctr2
.count
+= ruv
->count
;
1078 nuv
.ctr
.ctr2
.cursors
= talloc_array(ar
,
1079 struct drsuapi_DsReplicaCursor2
,
1080 nuv
.ctr
.ctr2
.count
);
1081 if (!nuv
.ctr
.ctr2
.cursors
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
1083 /* first copy the old vector */
1084 for (i
=0; i
< ouv
.ctr
.ctr2
.count
; i
++) {
1085 nuv
.ctr
.ctr2
.cursors
[ni
] = ouv
.ctr
.ctr2
.cursors
[i
];
1089 /* get our invocation_id if we have one already attached to the ldb */
1090 our_invocation_id
= samdb_ntds_invocation_id(ar
->module
->ldb
);
1092 /* merge in the source_dsa vector is available */
1093 for (i
=0; (ruv
&& i
< ruv
->count
); i
++) {
1096 if (our_invocation_id
&&
1097 GUID_equal(&ruv
->cursors
[i
].source_dsa_invocation_id
,
1098 our_invocation_id
)) {
1102 for (j
=0; j
< ni
; j
++) {
1103 if (!GUID_equal(&ruv
->cursors
[i
].source_dsa_invocation_id
,
1104 &nuv
.ctr
.ctr2
.cursors
[j
].source_dsa_invocation_id
)) {
1111 * we update only the highest_usn and not the latest_sync_success time,
1112 * because the last success stands for direct replication
1114 if (ruv
->cursors
[i
].highest_usn
> nuv
.ctr
.ctr2
.cursors
[j
].highest_usn
) {
1115 nuv
.ctr
.ctr2
.cursors
[j
].highest_usn
= ruv
->cursors
[i
].highest_usn
;
1120 if (found
) continue;
1122 /* if it's not there yet, add it */
1123 nuv
.ctr
.ctr2
.cursors
[ni
] = ruv
->cursors
[i
];
1128 * merge in the current highwatermark for the source_dsa
1131 for (j
=0; j
< ni
; j
++) {
1132 if (!GUID_equal(&ar
->objs
->source_dsa
->source_dsa_invocation_id
,
1133 &nuv
.ctr
.ctr2
.cursors
[j
].source_dsa_invocation_id
)) {
1140 * here we update the highest_usn and last_sync_success time
1141 * because we're directly replicating from the source_dsa
1143 * and use the tmp_highest_usn because this is what we have just applied
1146 nuv
.ctr
.ctr2
.cursors
[j
].highest_usn
= ar
->objs
->source_dsa
->highwatermark
.tmp_highest_usn
;
1147 nuv
.ctr
.ctr2
.cursors
[j
].last_sync_success
= now
;
1152 * here we update the highest_usn and last_sync_success time
1153 * because we're directly replicating from the source_dsa
1155 * and use the tmp_highest_usn because this is what we have just applied
1158 nuv
.ctr
.ctr2
.cursors
[ni
].source_dsa_invocation_id
= ar
->objs
->source_dsa
->source_dsa_invocation_id
;
1159 nuv
.ctr
.ctr2
.cursors
[ni
].highest_usn
= ar
->objs
->source_dsa
->highwatermark
.tmp_highest_usn
;
1160 nuv
.ctr
.ctr2
.cursors
[ni
].last_sync_success
= now
;
1165 * finally correct the size of the cursors array
1167 nuv
.ctr
.ctr2
.count
= ni
;
1172 qsort(nuv
.ctr
.ctr2
.cursors
, nuv
.ctr
.ctr2
.count
,
1173 sizeof(struct drsuapi_DsReplicaCursor2
),
1174 (comparison_fn_t
)replmd_drsuapi_DsReplicaCursor2_compare
);
1177 * create the change ldb_message
1179 msg
= ldb_msg_new(ar
);
1180 if (!msg
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
1181 msg
->dn
= ar
->search_msg
->dn
;
1183 ndr_err
= ndr_push_struct_blob(&nuv_value
, msg
,
1184 lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")),
1186 (ndr_push_flags_fn_t
)ndr_push_replUpToDateVectorBlob
);
1187 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
1188 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
1189 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
1191 ret
= ldb_msg_add_value(msg
, "replUpToDateVector", &nuv_value
, &nuv_el
);
1192 if (ret
!= LDB_SUCCESS
) {
1193 return replmd_replicated_request_error(ar
, ret
);
1195 nuv_el
->flags
= LDB_FLAG_MOD_REPLACE
;
1198 * now create the new repsFrom value from the given repsFromTo1 structure
1202 nrf
.ctr
.ctr1
= *ar
->objs
->source_dsa
;
1203 /* and fix some values... */
1204 nrf
.ctr
.ctr1
.consecutive_sync_failures
= 0;
1205 nrf
.ctr
.ctr1
.last_success
= now
;
1206 nrf
.ctr
.ctr1
.last_attempt
= now
;
1207 nrf
.ctr
.ctr1
.result_last_attempt
= WERR_OK
;
1208 nrf
.ctr
.ctr1
.highwatermark
.highest_usn
= nrf
.ctr
.ctr1
.highwatermark
.tmp_highest_usn
;
1211 * first see if we already have a repsFrom value for the current source dsa
1212 * if so we'll later replace this value
1214 orf_el
= ldb_msg_find_element(ar
->search_msg
, "repsFrom");
1216 for (i
=0; i
< orf_el
->num_values
; i
++) {
1217 struct repsFromToBlob
*trf
;
1219 trf
= talloc(ar
, struct repsFromToBlob
);
1220 if (!trf
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
1222 ndr_err
= ndr_pull_struct_blob(&orf_el
->values
[i
], trf
, lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")), trf
,
1223 (ndr_pull_flags_fn_t
)ndr_pull_repsFromToBlob
);
1224 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
1225 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
1226 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
1229 if (trf
->version
!= 1) {
1230 return replmd_replicated_request_werror(ar
, WERR_DS_DRA_INTERNAL_ERROR
);
1234 * we compare the source dsa objectGUID not the invocation_id
1235 * because we want only one repsFrom value per source dsa
1236 * and when the invocation_id of the source dsa has changed we don't need
1237 * the old repsFrom with the old invocation_id
1239 if (!GUID_equal(&trf
->ctr
.ctr1
.source_dsa_obj_guid
,
1240 &ar
->objs
->source_dsa
->source_dsa_obj_guid
)) {
1246 nrf_value
= &orf_el
->values
[i
];
1251 * copy over all old values to the new ldb_message
1253 ret
= ldb_msg_add_empty(msg
, "repsFrom", 0, &nrf_el
);
1254 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
1259 * if we haven't found an old repsFrom value for the current source dsa
1260 * we'll add a new value
1263 struct ldb_val zero_value
;
1264 ZERO_STRUCT(zero_value
);
1265 ret
= ldb_msg_add_value(msg
, "repsFrom", &zero_value
, &nrf_el
);
1266 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
1268 nrf_value
= &nrf_el
->values
[nrf_el
->num_values
- 1];
1271 /* we now fill the value which is already attached to ldb_message */
1272 ndr_err
= ndr_push_struct_blob(nrf_value
, msg
,
1273 lp_iconv_convenience(ldb_get_opaque(ar
->module
->ldb
, "loadparm")),
1275 (ndr_push_flags_fn_t
)ndr_push_repsFromToBlob
);
1276 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
1277 NTSTATUS nt_status
= ndr_map_error2ntstatus(ndr_err
);
1278 return replmd_replicated_request_werror(ar
, ntstatus_to_werror(nt_status
));
1282 * the ldb_message_element for the attribute, has all the old values and the new one
1283 * so we'll replace the whole attribute with all values
1285 nrf_el
->flags
= LDB_FLAG_MOD_REPLACE
;
1287 /* prepare the ldb_modify() request */
1288 ret
= ldb_build_mod_req(&change_req
,
1294 replmd_replicated_uptodate_modify_callback
,
1296 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
1298 return ldb_next_request(ar
->module
, change_req
);
1301 static int replmd_replicated_uptodate_search_callback(struct ldb_request
*req
,
1302 struct ldb_reply
*ares
)
1304 struct replmd_replicated_request
*ar
= talloc_get_type(req
->context
,
1305 struct replmd_replicated_request
);
1309 return ldb_module_done(ar
->req
, NULL
, NULL
,
1310 LDB_ERR_OPERATIONS_ERROR
);
1312 if (ares
->error
!= LDB_SUCCESS
&&
1313 ares
->error
!= LDB_ERR_NO_SUCH_OBJECT
) {
1314 return ldb_module_done(ar
->req
, ares
->controls
,
1315 ares
->response
, ares
->error
);
1318 switch (ares
->type
) {
1319 case LDB_REPLY_ENTRY
:
1320 ar
->search_msg
= talloc_steal(ar
, ares
->message
);
1323 case LDB_REPLY_REFERRAL
:
1324 /* we ignore referrals */
1327 case LDB_REPLY_DONE
:
1328 if (ar
->search_msg
== NULL
) {
1329 ret
= replmd_replicated_request_werror(ar
, WERR_DS_DRA_INTERNAL_ERROR
);
1331 ret
= replmd_replicated_uptodate_modify(ar
);
1333 if (ret
!= LDB_SUCCESS
) {
1334 return ldb_module_done(ar
->req
, NULL
, NULL
, ret
);
1343 static int replmd_replicated_uptodate_vector(struct replmd_replicated_request
*ar
)
1346 static const char *attrs
[] = {
1347 "replUpToDateVector",
1351 struct ldb_request
*search_req
;
1353 ar
->search_msg
= NULL
;
1355 ret
= ldb_build_search_req(&search_req
,
1358 ar
->objs
->partition_dn
,
1364 replmd_replicated_uptodate_search_callback
,
1366 if (ret
!= LDB_SUCCESS
) return replmd_replicated_request_error(ar
, ret
);
1368 return ldb_next_request(ar
->module
, search_req
);
1371 static int replmd_extended_replicated_objects(struct ldb_module
*module
, struct ldb_request
*req
)
1373 struct dsdb_extended_replicated_objects
*objs
;
1374 struct replmd_replicated_request
*ar
;
1375 struct ldb_control
**ctrls
;
1378 ldb_debug(module
->ldb
, LDB_DEBUG_TRACE
, "replmd_extended_replicated_objects\n");
1380 objs
= talloc_get_type(req
->op
.extended
.data
, struct dsdb_extended_replicated_objects
);
1382 ldb_debug(module
->ldb
, LDB_DEBUG_FATAL
, "replmd_extended_replicated_objects: invalid extended data\n");
1383 return LDB_ERR_PROTOCOL_ERROR
;
1386 if (objs
->version
!= DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION
) {
1387 ldb_debug(module
->ldb
, LDB_DEBUG_FATAL
, "replmd_extended_replicated_objects: extended data invalid version [%u != %u]\n",
1388 objs
->version
, DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION
);
1389 return LDB_ERR_PROTOCOL_ERROR
;
1392 ar
= replmd_ctx_init(module
, req
);
1394 return LDB_ERR_OPERATIONS_ERROR
;
1397 ar
->schema
= dsdb_get_schema(module
->ldb
);
1399 ldb_debug_set(module
->ldb
, LDB_DEBUG_FATAL
, "replmd_ctx_init: no loaded schema found\n");
1401 return LDB_ERR_CONSTRAINT_VIOLATION
;
1404 ctrls
= req
->controls
;
1406 if (req
->controls
) {
1407 req
->controls
= talloc_memdup(ar
, req
->controls
,
1408 talloc_get_size(req
->controls
));
1409 if (!req
->controls
) return replmd_replicated_request_werror(ar
, WERR_NOMEM
);
1412 ret
= ldb_request_add_control(req
, DSDB_CONTROL_REPLICATED_UPDATE_OID
, false, NULL
);
1413 if (ret
!= LDB_SUCCESS
) {
1417 ar
->controls
= req
->controls
;
1418 req
->controls
= ctrls
;
1420 return replmd_replicated_apply_next(ar
);
1423 static int replmd_extended(struct ldb_module
*module
, struct ldb_request
*req
)
1425 if (strcmp(req
->op
.extended
.oid
, DSDB_EXTENDED_REPLICATED_OBJECTS_OID
) == 0) {
1426 return replmd_extended_replicated_objects(module
, req
);
1429 return ldb_next_request(module
, req
);
1432 _PUBLIC_
const struct ldb_module_ops ldb_repl_meta_data_module_ops
= {
1433 .name
= "repl_meta_data",
1435 .modify
= replmd_modify
,
1436 .extended
= replmd_extended
,