return NT_STATUS_OK;
}
-static NTSTATUS libnet_vampire_cb_apply_schema(struct libnet_vampire_cb_state *s,
- const struct libnet_BecomeDC_StoreChunk *c)
+static WERROR libnet_vampire_cb_apply_schema(struct libnet_vampire_cb_state *s,
+ const struct libnet_BecomeDC_StoreChunk *c)
{
WERROR status;
struct dsdb_schema_prefixmap *pfm_remote;
DEBUG(0,("Analyze and apply schema objects\n"));
s_dsa = talloc_zero(s, struct repsFromTo1);
- NT_STATUS_HAVE_NO_MEMORY(s_dsa);
+ if (s_dsa == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
s_dsa->other_info = talloc(s_dsa, struct repsFromTo1OtherInfo);
- NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
+ if (s_dsa->other_info == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
switch (c->ctr_level) {
case 1:
uptodateness_vector = c->ctr6->uptodateness_vector;
break;
default:
- return NT_STATUS_INVALID_PARAMETER;
+ return WERR_INVALID_PARAMETER;
}
/* We must set these up to ensure the replMetaData is written
* correctly, before our NTDS Settings entry is replicated */
ok = samdb_set_ntds_invocation_id(s->ldb, &c->dest_dsa->invocation_id);
if (!ok) {
DEBUG(0,("Failed to set cached ntds invocationId\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
ok = samdb_set_ntds_objectGUID(s->ldb, &c->dest_dsa->ntds_guid);
if (!ok) {
DEBUG(0,("Failed to set cached ntds objectGUID\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
status = dsdb_schema_pfm_from_drsuapi_pfm(mapping_ctr, true,
if (!W_ERROR_IS_OK(status)) {
DEBUG(0,(__location__ ": Failed to decode remote prefixMap: %s",
win_errstr(status)));
- return werror_to_ntstatus(status);
+ return status;
}
s_dsa->replica_flags = DRSUAPI_DRS_WRIT_REP
memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
- NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ if (tmp_dns_name == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
- NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ if (tmp_dns_name == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
s_dsa->other_info->dns_name = tmp_dns_name;
if (s->self_made_schema == NULL) {
DEBUG(0,("libnet_vampire_cb_apply_schema: called with out self_made_schema\n"));
- return NT_STATUS_INTERNAL_ERROR;
+ return WERR_INTERNAL_ERROR;
}
schema_ldb = provision_get_schema(s, s->lp_ctx,
ret = dsdb_reference_schema(s->ldb, provision_schema, false);
if (ret != LDB_SUCCESS) {
DEBUG(0,("Failed to attach schema from local provision using remote prefixMap."));
- return NT_STATUS_UNSUCCESSFUL;
+ return WERR_INTERNAL_ERROR;
}
talloc_free(schema_ldb);
}
if (!W_ERROR_IS_OK(status)) {
DEBUG(0, ("%s: dsdb_repl_resolve_working_schema() failed: %s",
__location__, win_errstr(status)));
- return werror_to_ntstatus(status);
+ return status;
}
/* free temp objects for 1st conversion phase */
ret = dsdb_set_schema(s->ldb, s->self_made_schema);
if (ret != LDB_SUCCESS) {
DEBUG(0,("Failed to attach working schema from DRS.\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
/* we don't want to access the self made schema anymore */
partition_dn = ldb_dn_new(s, s->ldb, c->partition->nc.dn);
if (partition_dn == NULL) {
DEBUG(0,("Failed to parse partition DN from DRS.\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INVALID_PARAMETER;
}
/* Now convert the schema elements again, using the schema we finalised, ready to actually import */
s, &schema_objs);
if (!W_ERROR_IS_OK(status)) {
DEBUG(0,("Failed to convert objects when trying to import over DRS (2nd pass, to store remote schema): %s\n", win_errstr(status)));
- return werror_to_ntstatus(status);
+ return status;
}
if (lpcfg_parm_bool(s->lp_ctx, NULL, "become dc", "dump objects", false)) {
status = dsdb_replicated_objects_commit(s->ldb, NULL, schema_objs, &seq_num);
if (!W_ERROR_IS_OK(status)) {
DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
- return werror_to_ntstatus(status);
+ return status;
}
msg = ldb_msg_new(schema_objs);
- NT_STATUS_HAVE_NO_MEMORY(msg);
+ if (msg == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
msg->dn = schema_objs->partition_dn;
/* We must ensure a prefixMap has been written. Unlike other
* prefixMap for this entire operation. */
ret = ldb_msg_add_value(msg, "prefixMap", &s->prefixmap_blob, &prefixMap_el);
if (ret != LDB_SUCCESS) {
- return NT_STATUS_FOOBAR;
+ return WERR_NOT_ENOUGH_MEMORY;
}
/* We want to know if a prefixMap was written already, as it
* would mean that the above comment was not true, and we have
ret = dsdb_modify(s->ldb, msg, DSDB_FLAG_AS_SYSTEM);
if (ret != LDB_SUCCESS) {
DEBUG(0,("Failed to add prefixMap: %s\n", ldb_errstring(s->ldb)));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
talloc_free(s_dsa);
s->schema = dsdb_get_schema(s->ldb, s);
if (!s->schema) {
DEBUG(0,("Failed to get loaded dsdb_schema\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
- return NT_STATUS_OK;
+ return WERR_OK;
}
-NTSTATUS libnet_vampire_cb_schema_chunk(void *private_data,
- const struct libnet_BecomeDC_StoreChunk *c)
+WERROR libnet_vampire_cb_schema_chunk(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *c)
{
struct libnet_vampire_cb_state *s = talloc_get_type(private_data, struct libnet_vampire_cb_state);
- WERROR status;
+ WERROR werr;
const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
uint32_t nc_object_count;
uint32_t nc_total_received = 0;
linked_attributes_count = c->ctr6->linked_attributes_count;
break;
default:
- return NT_STATUS_INVALID_PARAMETER;
+ return WERR_INVALID_PARAMETER;
}
if (!s->schema_part.first_object) {
}
if (!s->self_made_schema) {
- WERROR werr;
struct drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr_without_schema_info;
/* Put the DRS prefixmap aside for the schema we are
* about to load in the provision, and into the one we
}
werr = dsdb_get_drsuapi_prefixmap_as_blob(&mapping_ctr_without_schema_info, s, &s->prefixmap_blob);
if (!W_ERROR_IS_OK(werr)) {
- return werror_to_ntstatus(werr);
+ return werr;
}
/* Set up two manually-constructed schema - the local
* one, which will then in turn be used to build the
* other. */
s->self_made_schema = dsdb_new_schema(s);
- NT_STATUS_HAVE_NO_MEMORY(s->self_made_schema);
+ if (s->self_made_schema == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
- status = dsdb_load_prefixmap_from_drsuapi(s->self_made_schema, mapping_ctr);
- if (!W_ERROR_IS_OK(status)) {
- return werror_to_ntstatus(status);
+ werr = dsdb_load_prefixmap_from_drsuapi(s->self_made_schema, mapping_ctr);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
}
} else {
- status = dsdb_schema_pfm_contains_drsuapi_pfm(s->self_made_schema->prefixmap, mapping_ctr);
- if (!W_ERROR_IS_OK(status)) {
- return werror_to_ntstatus(status);
+ werr = dsdb_schema_pfm_contains_drsuapi_pfm(s->self_made_schema->prefixmap, mapping_ctr);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
}
}
return libnet_vampire_cb_apply_schema(s, c);
}
- return NT_STATUS_OK;
+ return WERR_OK;
}
-NTSTATUS libnet_vampire_cb_store_chunk(void *private_data,
- const struct libnet_BecomeDC_StoreChunk *c)
+WERROR libnet_vampire_cb_store_chunk(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *c)
{
struct libnet_vampire_cb_state *s = talloc_get_type(private_data, struct libnet_vampire_cb_state);
WERROR status;
struct ldb_dn *nc_root = NULL;
s_dsa = talloc_zero(s, struct repsFromTo1);
- NT_STATUS_HAVE_NO_MEMORY(s_dsa);
+ if (s_dsa == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
s_dsa->other_info = talloc(s_dsa, struct repsFromTo1OtherInfo);
- NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
+ if (s_dsa->other_info == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
switch (c->ctr_level) {
case 1:
uptodateness_vector = c->ctr6->uptodateness_vector;
break;
default:
- return NT_STATUS_INVALID_PARAMETER;
+ return WERR_INVALID_PARAMETER;
}
switch (c->req_level) {
req_replica_flags = c->req10->replica_flags;
break;
default:
- return NT_STATUS_INVALID_PARAMETER;
+ return WERR_INVALID_PARAMETER;
}
if (req_replica_flags & DRSUAPI_DRS_CRITICAL_ONLY) {
memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
- NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ if (tmp_dns_name == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
- NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ if (tmp_dns_name == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
s_dsa->other_info->dns_name = tmp_dns_name;
/* we want to show a count per partition */
partition_dn = ldb_dn_new(s, s->ldb, c->partition->nc.dn);
if (partition_dn == NULL) {
DEBUG(0,("Failed to parse partition DN from DRS.\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INVALID_PARAMETER;
}
if (is_exop) {
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ ": Failed to find nc_root for %s\n",
ldb_dn_get_linearized(partition_dn)));
- return NT_STATUS_INTERNAL_ERROR;
+ return WERR_INTERNAL_ERROR;
}
} else {
if (nc_object_count) {
schema = dsdb_get_schema(s->ldb, NULL);
if (!schema) {
DEBUG(0,(__location__ ": Schema is not loaded yet!\n"));
- return NT_STATUS_INTERNAL_ERROR;
+ return WERR_INTERNAL_ERROR;
}
if (req_replica_flags & DRSUAPI_DRS_FULL_SYNC_IN_PROGRESS) {
s, &objs);
if (!W_ERROR_IS_OK(status)) {
DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status)));
- return werror_to_ntstatus(status);
+ return status;
}
if (lpcfg_parm_bool(s->lp_ctx, NULL, "become dc", "dump objects", false)) {
status = dsdb_replicated_objects_commit(s->ldb, NULL, objs, &seq_num);
if (!W_ERROR_IS_OK(status)) {
DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
- return werror_to_ntstatus(status);
+ return status;
}
talloc_free(s_dsa);
if (!linked_attributes[i].identifier) {
DEBUG(0, ("No linked attribute identifier\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
if (!linked_attributes[i].value.blob) {
DEBUG(0, ("No linked attribute value\n"));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
sa = dsdb_attribute_by_attributeID_id(s->schema,
linked_attributes[i].attid);
if (!sa) {
DEBUG(0, ("Unable to find attribute via attribute id %d\n", linked_attributes[i].attid));
- return NT_STATUS_FOOBAR;
+ return WERR_INTERNAL_ERROR;
}
if (lpcfg_parm_bool(s->lp_ctx, NULL, "become dc", "dump objects", false)) {
}
}
- return NT_STATUS_OK;
+ return WERR_OK;
}