static WERROR _dsdb_syntax_OID_obj_drsuapi_to_ldb(struct ldb_context *ldb, const struct dsdb_schema *schema, const struct dsdb_attribute *attr, const struct drsuapi_DsReplicaAttribute *in, TALLOC_CTX *mem_ctx, struct ldb_message_element *out) { uint32_t i; out->flags = 0; out->name = talloc_strdup(mem_ctx, attr->lDAPDisplayName); W_ERROR_HAVE_NO_MEMORY(out->name); out->num_values = in->value_ctr.num_values; out->values = talloc_array(mem_ctx, struct ldb_val, out->num_values); W_ERROR_HAVE_NO_MEMORY(out->values); for (i=0; i < out->num_values; i++) { uint32_t v; const struct dsdb_class *c; const char *str; if (in->value_ctr.values[i].blob == NULL) { return WERR_FOOBAR; } if (in->value_ctr.values[i].blob->length != 4) { return WERR_FOOBAR; } v = IVAL(in->value_ctr.values[i].blob->data, 0); c = dsdb_class_by_governsID_id(schema, v); if (!c) { return WERR_FOOBAR; } str = talloc_strdup(out->values, c->lDAPDisplayName); W_ERROR_HAVE_NO_MEMORY(str); /* the values need to be reversed */ out->values[out->num_values - (i + 1)] = data_blob_string_const(str); } return WERR_OK; }
const char *dsdb_lDAPDisplayName_by_id(const struct dsdb_schema *schema, uint32_t id) { const struct dsdb_attribute *a; const struct dsdb_class *c; a = dsdb_attribute_by_attributeID_id(schema, id); if (a) { return a->lDAPDisplayName; } c = dsdb_class_by_governsID_id(schema, id); if (c) { return c->lDAPDisplayName; } return NULL; }
static WERROR dsdb_repl_merge_working_schema(struct ldb_context *ldb, struct dsdb_schema *dest_schema, const struct dsdb_schema *ref_schema) { const struct dsdb_class *cur_class = NULL; const struct dsdb_attribute *cur_attr = NULL; int ret; for (cur_class = ref_schema->classes; cur_class; cur_class = cur_class->next) { const struct dsdb_class *tmp1; struct dsdb_class *tmp2; tmp1 = dsdb_class_by_governsID_id(dest_schema, cur_class->governsID_id); if (tmp1 != NULL) { continue; } /* * Do a shallow copy so that original next and prev are * not modified, we don't need to do a deep copy * as the rest won't be modified and this is for * a short lived object. */ tmp2 = talloc(dest_schema, struct dsdb_class); if (tmp2 == NULL) { return WERR_NOMEM; } *tmp2 = *cur_class; DLIST_ADD(dest_schema->classes, tmp2); } for (cur_attr = ref_schema->attributes; cur_attr; cur_attr = cur_attr->next) { const struct dsdb_attribute *tmp1; struct dsdb_attribute *tmp2; tmp1 = dsdb_attribute_by_attributeID_id(dest_schema, cur_attr->attributeID_id); if (tmp1 != NULL) { continue; } /* * Do a shallow copy so that original next and prev are * not modified, we don't need to do a deep copy * as the rest won't be modified and this is for * a short lived object. */ tmp2 = talloc(dest_schema, struct dsdb_attribute); if (tmp2 == NULL) { return WERR_NOMEM; } *tmp2 = *cur_attr; DLIST_ADD(dest_schema->attributes, tmp2); } ret = dsdb_setup_sorted_accessors(ldb, dest_schema); if (LDB_SUCCESS != ret) { DEBUG(0,("Failed to add new attribute to reference schema!\n")); return WERR_INTERNAL_ERROR; } return WERR_OK; }