/*
* Name: ldb
*
- * Component: ldb instancetype module
+ * Component: ldb new partition module
*
- * Description: add an instanceType onto every new record
+ * Description: Handle the add of new partitions
*
* Author: Andrew Bartlett
*/
#include "librpc/gen_ndr/ndr_misc.h"
#include "dsdb/samdb/samdb.h"
#include "../libds/common/flags.h"
+#include "dsdb/common/util.h"
struct np_context {
struct ldb_module *module;
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(ldb, "Invalid reply type!");
+ ldb_asprintf_errstring(ldb, "Invalid LDB reply type %d", ares->type);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
ret = ldb_build_extended_req(&ac->part_add,
ldb, ac, DSDB_EXTENDED_CREATE_PARTITION_OID, ex_op,
NULL, ac, np_part_mod_callback, req);
+
+ /* if the parent was asking for a partial replica, then we
+ * need the extended operation to also ask for a partial
+ * replica */
+ if (ldb_request_get_control(req, DSDB_CONTROL_PARTIAL_REPLICA)) {
+ ret = dsdb_request_add_controls(ac->part_add, DSDB_MODIFY_PARTIAL_REPLICA);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
LDB_REQ_SET_LOCATION(ac->part_add);
if (ret != LDB_SUCCESS) {
ldb = ldb_module_get_ctx(module);
- ldb_debug(ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n");
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "new_partition_add\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
if (ldb_msg_find_element(req->op.add.message, "instanceType")) {
/* This needs to be 'static' to ensure it does not move, and is not on the stack */
static const char *no_attrs[] = { NULL };
- unsigned int instanceType = ldb_msg_find_attr_as_uint(req->op.add.message, "instanceType", 0);
- if (!(instanceType & INSTANCE_TYPE_IS_NC_HEAD) ||
- (instanceType & INSTANCE_TYPE_UNINSTANT)) {
- return ldb_next_request(module, req);
- }
+ uint32_t instanceType = ldb_msg_find_attr_as_uint(req->op.add.message, "instanceType", 0);
- if (instanceType & INSTANCE_TYPE_UNINSTANT) {
- DEBUG(0,(__location__ ": Skipping uninstantiated partition %s\n",
- ldb_dn_get_linearized(req->op.add.message->dn)));
+ if (!(instanceType & INSTANCE_TYPE_IS_NC_HEAD)) {
return ldb_next_request(module, req);
}
int ldb_new_partition_module_init(const char *version)
{
+ LDB_MODULE_CHECK_VERSION(version);
return ldb_register_module(&ldb_new_partition_module_ops);
}