diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-09-28 11:04:29 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-10-04 15:08:57 +1100 |
commit | 60cbc98051b430fc09358a09866c69a54cc726bc (patch) | |
tree | 7b8568e7fbc1b1b32396ba537d952192f55631ff /source4/dsdb/common | |
parent | fb937afbecb61896e8e8e56c19bbc193fc573e15 (diff) | |
download | samba-60cbc98051b430fc09358a09866c69a54cc726bc.tar.gz samba-60cbc98051b430fc09358a09866c69a54cc726bc.tar.bz2 samba-60cbc98051b430fc09358a09866c69a54cc726bc.zip |
s4-dsdb: added new control DSDB_MODIFY_PARTIAL_REPLICA
this control tells the partition module that the DN being created is a
partial replica, so it should modify the @PARTITION object to add the
partialReplica attribute
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb/common')
-rw-r--r-- | source4/dsdb/common/util.c | 66 | ||||
-rw-r--r-- | source4/dsdb/common/util.h | 1 |
2 files changed, 67 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index cf28f1dd01..3a55a55306 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -3751,6 +3751,13 @@ int dsdb_request_add_controls(struct ldb_request *req, uint32_t dsdb_flags) } } + if (dsdb_flags & DSDB_MODIFY_PARTIAL_REPLICA) { + ret = ldb_request_add_control(req, DSDB_CONTROL_PARTIAL_REPLICA, false, NULL); + if (ret != LDB_SUCCESS) { + return ret; + } + } + return LDB_SUCCESS; } @@ -4467,3 +4474,62 @@ NTSTATUS dsdb_ldb_err_to_ntstatus(int err) } return NT_STATUS_UNSUCCESSFUL; } + + +/* + create a new naming context that will hold a partial replica + */ +int dsdb_create_partial_replica_NC(struct ldb_context *ldb, struct ldb_dn *dn) +{ + TALLOC_CTX *tmp_ctx = talloc_new(ldb); + struct ldb_message *msg; + int ret; + + msg = ldb_msg_new(tmp_ctx); + if (msg == NULL) { + talloc_free(tmp_ctx); + return ldb_oom(ldb); + } + + msg->dn = dn; + ret = ldb_msg_add_string(msg, "objectClass", "top"); + if (ret != LDB_SUCCESS) { + talloc_free(tmp_ctx); + return ldb_oom(ldb); + } + + /* [MS-DRSR] implies that we should only add the 'top' + * objectclass, but that would cause lots of problems with our + * objectclass code as top is not structural, so we add + * 'domainDNS' as well to keep things sane. We're expecting + * this new NC to be of objectclass domainDNS after + * replication anyway + */ + ret = ldb_msg_add_string(msg, "objectClass", "domainDNS"); + if (ret != LDB_SUCCESS) { + talloc_free(tmp_ctx); + return ldb_oom(ldb); + } + + ret = ldb_msg_add_fmt(msg, "instanceType", "%u", + INSTANCE_TYPE_IS_NC_HEAD| + INSTANCE_TYPE_NC_ABOVE| + INSTANCE_TYPE_UNINSTANT); + if (ret != LDB_SUCCESS) { + talloc_free(tmp_ctx); + return ldb_oom(ldb); + } + + ret = dsdb_add(ldb, msg, DSDB_MODIFY_PARTIAL_REPLICA); + if (ret != LDB_SUCCESS) { + DEBUG(0,("Failed to create new NC for %s - %s\n", + ldb_dn_get_linearized(dn), ldb_errstring(ldb))); + talloc_free(tmp_ctx); + return ret; + } + + DEBUG(1,("Created new NC for %s\n", ldb_dn_get_linearized(dn))); + + talloc_free(tmp_ctx); + return LDB_SUCCESS; +} diff --git a/source4/dsdb/common/util.h b/source4/dsdb/common/util.h index 75ef49e1c3..b2f7aa5b32 100644 --- a/source4/dsdb/common/util.h +++ b/source4/dsdb/common/util.h @@ -37,6 +37,7 @@ #define DSDB_PROVISION 0x0800 #define DSDB_BYPASS_PASSWORD_HASH 0x1000 #define DSDB_SEARCH_NO_GLOBAL_CATALOG 0x2000 +#define DSDB_MODIFY_PARTIAL_REPLICA 0x4000 bool is_attr_in_list(const char * const * attrs, const char *attr); |