diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-01-06 01:13:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:37:06 -0500 |
commit | 3137e4f2fe036824984352edf618a8eddde17c51 (patch) | |
tree | e9bdd334bd35a5015f4546911e59bc08d8d8f483 /source4/dsdb/samdb | |
parent | 13881fa128d1e48b947512159271aae3f51b3572 (diff) | |
download | samba-3137e4f2fe036824984352edf618a8eddde17c51.tar.gz samba-3137e4f2fe036824984352edf618a8eddde17c51.tar.bz2 samba-3137e4f2fe036824984352edf618a8eddde17c51.zip |
r20580: pass the DSDB_CONTROL_REPLICATED_OBJECT_OID with the ldb_add request
when applying replicated objects.
the samldb module ignores such requests now...
and the repl_meta_data module has different functions
for the replicated and originating cases...
metze
(This used to be commit a4d5e0126cfd6135ab829f4984269e265a868a28)
Diffstat (limited to 'source4/dsdb/samdb')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 95 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/samldb.c | 5 | ||||
-rw-r--r-- | source4/dsdb/samdb/samdb.h | 5 |
3 files changed, 88 insertions, 17 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index d9ad9d6e51..171af52eda 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -40,8 +40,11 @@ */ #include "includes.h" -#include "ldb/include/includes.h" +#include "lib/ldb/include/ldb.h" +#include "lib/ldb/include/ldb_errors.h" +#include "lib/ldb/include/ldb_private.h" #include "librpc/gen_ndr/ndr_misc.h" +#include "dsdb/samdb/samdb.h" static struct ldb_message_element *replmd_find_attribute(const struct ldb_message *msg, const char *name) { @@ -108,8 +111,24 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ return 0; } -/* add_record: add objectGUID attribute */ -static int replmd_add(struct ldb_module *module, struct ldb_request *req) +static int replmd_add_replicated(struct ldb_module *module, struct ldb_request *req, struct ldb_control *ctrl) +{ + struct ldb_control **saved_ctrls; + int ret; + + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add_replicated\n"); + + if (!save_controls(ctrl, req, &saved_ctrls)) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_next_request(module, req); + req->controls = saved_ctrls; + + return ret; +} + +static int replmd_add_originating(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *down_req; struct ldb_message_element *attribute; @@ -121,12 +140,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) int ret; time_t t = time(NULL); - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add_record\n"); - - /* do not manipulate our control entries */ - if (ldb_dn_is_special(req->op.add.message->dn)) { - return ldb_next_request(module, req); - } + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add_originating\n"); if ((attribute = replmd_find_attribute(req->op.add.message, "objectGUID")) != NULL ) { return ldb_next_request(module, req); @@ -192,8 +206,42 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) return ret; } -/* modify_record: update timestamps */ -static int replmd_modify(struct ldb_module *module, struct ldb_request *req) +static int replmd_add(struct ldb_module *module, struct ldb_request *req) +{ + struct ldb_control *ctrl; + + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.add.message->dn)) { + return ldb_next_request(module, req); + } + + ctrl = get_control_from_list(req->controls, DSDB_CONTROL_REPLICATED_OBJECT_OID); + if (ctrl) { + /* handle replicated objects different */ + return replmd_add_replicated(module, req, ctrl); + } + + return replmd_add_originating(module, req); +} + +static int replmd_modify_replicated(struct ldb_module *module, struct ldb_request *req, struct ldb_control *ctrl) +{ + struct ldb_control **saved_ctrls; + int ret; + + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify_replicated\n"); + + if (!save_controls(ctrl, req, &saved_ctrls)) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_next_request(module, req); + req->controls = saved_ctrls; + + return ret; +} + +static int replmd_modify_originating(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *down_req; struct ldb_message *msg; @@ -201,12 +249,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) time_t t = time(NULL); uint64_t seq_num; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); - - /* do not manipulate our control entries */ - if (ldb_dn_is_special(req->op.add.message->dn)) { - return ldb_next_request(module, req); - } + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify_originating\n"); down_req = talloc(req, struct ldb_request); if (down_req == NULL) { @@ -250,6 +293,24 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) return ret; } +static int replmd_modify(struct ldb_module *module, struct ldb_request *req) +{ + struct ldb_control *ctrl; + + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.mod.message->dn)) { + return ldb_next_request(module, req); + } + + ctrl = get_control_from_list(req->controls, DSDB_CONTROL_REPLICATED_OBJECT_OID); + if (ctrl) { + /* handle replicated objects different */ + return replmd_modify_replicated(module, req, ctrl); + } + + return replmd_modify_originating(module, req); +} + static const struct ldb_module_ops replmd_ops = { .name = "repl_meta_data", .add = replmd_add, diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 1c1ff0ea6e..07d77ee3fc 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -680,6 +680,11 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + if (get_control_from_list(req->controls, DSDB_CONTROL_REPLICATED_OBJECT_OID)) { + /* if it's a replicated object we have nothing to do */ + return ldb_next_request(module, req); + } + /* is user or computer? */ if ((samdb_find_attribute(module->ldb, msg, "objectclass", "user") != NULL) || (samdb_find_attribute(module->ldb, msg, "objectclass", "computer") != NULL)) { diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 8ff44f7554..7d16b2d380 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -29,6 +29,11 @@ struct drsuapi_DsReplicaObject; struct drsuapi_DsReplicaOIDMapping_Ctr; struct drsuapi_DsReplicaAttribute; +#define DSDB_CONTROL_REPLICATED_OBJECT_OID "1.3.6.1.4.1.7165.4.3.1" +struct dsdb_control_replicated_object { + uint8_t __dummy; +}; + #include "librpc/gen_ndr/security.h" #include "lib/ldb/include/ldb.h" #include "librpc/gen_ndr/samr.h" |