}
}
},
+ {
+ .local_name = "objectClasses",
+ .type = MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaObjectClasses"
+ }
+ }
+ },
{
.local_name = "sambaPassword",
.type = MAP_RENAME,
}
};
+/* This objectClass conflicts with builtin classes on OpenLDAP */
+const struct ldb_map_objectclass entryUUID_objectclasses[] =
+{
+ {
+ .local_name = "subSchema",
+ .remote_name = "samba4SubSchema"
+ },
+ {
+ .local_name = NULL
+ }
+};
+
/* These things do not show up in wildcard searches in OpenLDAP, but
* we need them to show up in the AD-like view */
-const char * const wildcard_attributes[] = {
+const char * const entryUUID_wildcard_attributes[] = {
"objectGUID",
"whenCreated",
"whenChanged",
},
},
},
- /* objectSid */
+ /* objectSid */
{
.local_name = "objectSid",
.type = MAP_CONVERT,
struct entryUUID_private *entryUUID_private;
struct ldb_dn *schema_dn;
- ret = ldb_map_init(module, entryUUID_attributes, NULL, wildcard_attributes, NULL);
+ ret = ldb_map_init(module, entryUUID_attributes, entryUUID_objectclasses, entryUUID_wildcard_attributes, NULL);
if (ret != LDB_SUCCESS)
return ret;
char *old_oid;
char *new_oid;
} *oid_map = NULL;
- int num_maps = 0;
+ int num_oid_maps = 0;
+ struct attr_map {
+ char *old_attr;
+ char *new_attr;
+ } *attr_map = NULL;
+ int num_attr_maps = 0;
struct ldb_result *attrs_res, *objectclasses_res;
struct ldb_dn *schemadn;
struct schema_conv ret;
if (isdigit(line[0])) {
char *p = strchr(line, ':');
IF_NULL_FAIL_RET(p);
- if (!p) {
- ret.failures = 1;
- return ret;
- }
p[0] = '\0';
p++;
- oid_map = talloc_realloc(mem_ctx, oid_map, struct oid_map, num_maps + 2);
+ oid_map = talloc_realloc(mem_ctx, oid_map, struct oid_map, num_oid_maps + 2);
trim_string(line, " ", " ");
- oid_map[num_maps].old_oid = talloc_move(oid_map, &line);
+ oid_map[num_oid_maps].old_oid = talloc_move(oid_map, &line);
trim_string(p, " ", " ");
- oid_map[num_maps].new_oid = p;
- num_maps++;
- oid_map[num_maps].old_oid = NULL;
+ oid_map[num_oid_maps].new_oid = p;
+ num_oid_maps++;
+ oid_map[num_oid_maps].old_oid = NULL;
} else {
- attrs_skip = talloc_realloc(mem_ctx, attrs_skip, const char *, num_skip + 2);
- trim_string(line, " ", " ");
- attrs_skip[num_skip] = talloc_move(attrs_skip, &line);
- num_skip++;
- attrs_skip[num_skip] = NULL;
+ char *p = strchr(line, ':');
+ if (p) {
+ /* remap attribute/objectClass */
+ p[0] = '\0';
+ p++;
+ attr_map = talloc_realloc(mem_ctx, attr_map, struct attr_map, num_attr_maps + 2);
+ trim_string(line, " ", " ");
+ attr_map[num_attr_maps].old_attr = talloc_move(attr_map, &line);
+ trim_string(p, " ", " ");
+ attr_map[num_attr_maps].new_attr = p;
+ num_attr_maps++;
+ attr_map[num_attr_maps].old_attr = NULL;
+ } else {
+ /* skip attribute/objectClass */
+ attrs_skip = talloc_realloc(mem_ctx, attrs_skip, const char *, num_skip + 2);
+ trim_string(line, " ", " ");
+ attrs_skip[num_skip] = talloc_move(attrs_skip, &line);
+ num_skip++;
+ attrs_skip[num_skip] = NULL;
+ }
}
}
if (!name) {
printf("Failed to find lDAPDisplayName for schema DN: %s\n", ldb_dn_get_linearized(msg->dn));
- ret.failures = 1;
+ ret.failures++;
continue;
}
}
IF_NULL_FAIL_RET(schema_entry);
+ /* We might have been asked to remap this name, due to a conflict */
+ for (j=0; name && attr_map && attr_map[j].old_attr; j++) {
+ if (strcmp(name, attr_map[j].old_attr) == 0) {
+ name = attr_map[j].new_attr;
+ break;
+ }
+ }
+
schema_entry = talloc_asprintf_append(schema_entry,
" NAME '%s'\n", name);
IF_NULL_FAIL_RET(schema_entry);
char *schema_entry = NULL;
int j;
+ if (!name) {
+ printf("Failed to find lDAPDisplayName for schema DN: %s\n", ldb_dn_get_linearized(msg->dn));
+ ret.failures++;
+ continue;
+ }
+
/* We have been asked to skip some attributes/objectClasses */
if (attrs_skip && str_list_check_ci(attrs_skip, name)) {
ret.skipped++;
break;
}
+ /* We might have been asked to remap this name, due to a conflict */
+ for (j=0; name && attr_map && attr_map[j].old_attr; j++) {
+ if (strcmp(name, attr_map[j].old_attr) == 0) {
+ name = attr_map[j].new_attr;
+ break;
+ }
+ }
+
schema_entry = talloc_asprintf_append(schema_entry,
" NAME '%s'\n", name);
IF_NULL_FAIL_RET(schema_entry);
do { \
int k; \
for (k=0; attributes && k < attributes->num_values; k++) { \
+ int attr_idx; \
+ const char *attr_name = (const char *)attributes->values[k].data; \
+ /* We might have been asked to remap this name, due to a conflict */ \
+ for (attr_idx=0; attr_name && attr_map && attr_map[attr_idx].old_attr; attr_idx++) { \
+ if (strcmp(attr_name, attr_map[attr_idx].old_attr) == 0) { \
+ attr_name = attr_map[attr_idx].new_attr; \
+ break; \
+ } \
+ } \
+ \
schema_entry = talloc_asprintf_append(schema_entry, \
" %s", \
- (const char *)attributes->values[k].data); \
+ attr_name); \
IF_NULL_FAIL_RET(schema_entry); \
if (k != (attributes->num_values - 1)) { \
schema_entry = talloc_asprintf_append(schema_entry, \