const char **must;
const char **may;
char *schema_entry = NULL;
- const char *objectclass_name_as_list[] = {
- objectclass->lDAPDisplayName,
- NULL
+ struct ldb_val objectclass_name_as_ldb_val = data_blob_string_const(objectclass->lDAPDisplayName);
+ struct ldb_message_element objectclass_name_as_el = {
+ .name = "objectClass",
+ .num_values = 1,
+ .values = &objectclass_name_as_ldb_val
};
- int j;
- int attr_idx;
+ unsigned int j;
+ unsigned int attr_idx;
if (!mem_ctx) {
DEBUG(0, ("Failed to create new talloc context\n"));
}
}
- may = dsdb_full_attribute_list(mem_ctx, schema, objectclass_name_as_list, DSDB_SCHEMA_ALL_MAY);
+ /* We might have been asked to remap this subClassOf, due to a conflict */
+ for (j=0; subClassOf && attr_map && attr_map[j].old_attr; j++) {
+ if (strcasecmp(subClassOf, attr_map[j].old_attr) == 0) {
+ subClassOf = attr_map[j].new_attr;
+ break;
+ }
+ }
+
+ may = dsdb_full_attribute_list(mem_ctx, schema, &objectclass_name_as_el, DSDB_SCHEMA_ALL_MAY);
for (j=0; may && may[j]; j++) {
/* We might have been asked to remap this name, due to a conflict */
}
}
- must = dsdb_full_attribute_list(mem_ctx, schema, objectclass_name_as_list, DSDB_SCHEMA_ALL_MUST);
+ must = dsdb_full_attribute_list(mem_ctx, schema, &objectclass_name_as_el, DSDB_SCHEMA_ALL_MUST);
for (j=0; must && must[j]; j++) {
/* We might have been asked to remap this name, due to a conflict */
may,
NULL);
if (schema_entry == NULL) {
+ talloc_free(mem_ctx);
DEBUG(0, ("failed to generate schema description for %s\n", name));
return NULL;
}
case TARGET_FEDORA_DS:
out = talloc_asprintf_append(out, "objectClasses: %s\n", schema_entry);
break;
+ default:
+ talloc_free(mem_ctx);
+ DEBUG(0,(__location__ " Wrong type of target %u!", (unsigned)target));
+ return NULL;
}
talloc_free(mem_ctx);
} while (0);
char *line;
char *out;
const char **attrs_skip = NULL;
- int num_skip = 0;
+ unsigned int num_skip = 0;
struct oid_map *oid_map = NULL;
- int num_oid_maps = 0;
+ unsigned int num_oid_maps = 0;
struct attr_map *attr_map = NULL;
- int num_attr_maps = 0;
+ unsigned int num_attr_maps = 0;
struct dsdb_attribute *attribute;
struct dsdb_schema *schema;
enum dsdb_schema_convert_target target;
} else if (strcasecmp(target_str, "fedora-ds") == 0) {
target = TARGET_FEDORA_DS;
} else {
+ talloc_free(mem_ctx);
DEBUG(0, ("Invalid target type for schema conversion %s\n", target_str));
return NULL;
}
- /* The mappings are line-seperated, and specify details such as OIDs to skip etc */
+ /* The mappings are line-separated, and specify details such as OIDs to skip etc */
while (1) {
line = next_line;
next_line = strchr(line, '\n');
}
}
- schema = dsdb_get_schema(ldb);
+ schema = dsdb_get_schema(ldb, mem_ctx);
if (!schema) {
+ talloc_free(mem_ctx);
DEBUG(0, ("No schema on ldb to convert!\n"));
return NULL;
}
case TARGET_FEDORA_DS:
out = talloc_strdup(mem_ctx, "dn: cn=schema\n");
break;
+ default:
+ talloc_free(mem_ctx);
+ DEBUG(0,(__location__ " Wrong type of target %u!", (unsigned)target));
+ return NULL;
}
for (attribute=schema->attributes; attribute; attribute = attribute->next) {
bool single_value = attribute->isSingleValued;
char *schema_entry = NULL;
- int j;
+ unsigned int j;
/* We have been asked to skip some attributes/objectClasses */
if (attrs_skip && str_list_check_ci(attrs_skip, name)) {
false, false);
if (schema_entry == NULL) {
+ talloc_free(mem_ctx);
DEBUG(0, ("failed to generate attribute description for %s\n", name));
return NULL;
}
case TARGET_FEDORA_DS:
out = talloc_asprintf_append(out, "attributeTypes: %s\n", schema_entry);
break;
+ default:
+ talloc_free(mem_ctx);
+ DEBUG(0,(__location__ " Wrong type of target %u!", (unsigned)target));
+ return NULL;
}
}
out = print_schema_recursive(out, schema, "top", target, attrs_skip, attr_map, oid_map);
+ talloc_steal(ldb, out);
+ talloc_free(mem_ctx);
+
return out;
}