This allows objectClass munging to be removed, or modified to not
include adding an objectClass, or for that objectClass to be something
different.
Andrew Bartlett
(This used to be commit
ee93b4e2ee1dd1cd38bcf14b2bb62556a13cec4a)
- ret = ldb_map_init(module, samba3_attributes, samba3_objectclasses, NULL, "samba3sam");
+ ret = ldb_map_init(module, samba3_attributes, samba3_objectclasses, NULL, NULL, "samba3sam");
if (ret != LDB_SUCCESS)
return ret;
if (ret != LDB_SUCCESS)
return ret;
struct map_private *map_private;
struct entryuuid_private *entryuuid_private;
struct map_private *map_private;
struct entryuuid_private *entryuuid_private;
- ret = ldb_map_init(module, entryuuid_attributes, entryuuid_objectclasses, entryuuid_wildcard_attributes, NULL);
+ ret = ldb_map_init(module, entryuuid_attributes, entryuuid_objectclasses, entryuuid_wildcard_attributes, "extensibleObject", NULL);
if (ret != LDB_SUCCESS)
return ret;
if (ret != LDB_SUCCESS)
return ret;
struct map_private *map_private;
struct entryuuid_private *entryuuid_private;
struct map_private *map_private;
struct entryuuid_private *entryuuid_private;
- ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, NULL);
+ ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, "extensibleObject", NULL);
if (ret != LDB_SUCCESS)
return ret;
if (ret != LDB_SUCCESS)
return ret;
/* Generate a remote message with a mapped objectClass. */
static void map_objectclass_generate_remote(struct ldb_module *module, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local)
{
/* Generate a remote message with a mapped objectClass. */
static void map_objectclass_generate_remote(struct ldb_module *module, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local)
{
+ const struct ldb_map_context *data = map_get_context(module);
struct ldb_message_element *el, *oc;
struct ldb_val val;
bool found_extensibleObject = false;
struct ldb_message_element *el, *oc;
struct ldb_val val;
bool found_extensibleObject = false;
/* Convert all local objectClasses */
for (i = 0; i < el->num_values - 1; i++) {
el->values[i] = map_objectclass_convert_local(module, el->values, &oc->values[i]);
/* Convert all local objectClasses */
for (i = 0; i < el->num_values - 1; i++) {
el->values[i] = map_objectclass_convert_local(module, el->values, &oc->values[i]);
- if (ldb_attr_cmp((char *)el->values[i].data, "extensibleObject") == 0) {
+ if (ldb_attr_cmp((char *)el->values[i].data, data->add_objectclass) == 0) {
found_extensibleObject = true;
}
}
if (!found_extensibleObject) {
found_extensibleObject = true;
}
}
if (!found_extensibleObject) {
- val.data = (uint8_t *)talloc_strdup(el->values, "extensibleObject");
+ val.data = (uint8_t *)talloc_strdup(el->values, data->add_objectclass);
val.length = strlen((char *)val.data);
val.length = strlen((char *)val.data);
- /* Append additional objectClass "extensibleObject" */
+ /* Append additional objectClass data->add_objectclass */
el->values[i] = val;
} else {
el->num_values--;
el->values[i] = val;
} else {
el->num_values--;
+static const struct ldb_map_attribute objectclass_convert_map = {
+ .local_name = "objectClass",
+ .type = MAP_CONVERT,
+ .u = {
+ .convert = {
+ .remote_name = "objectClass",
+ .convert_local = map_objectclass_convert_local,
+ .convert_remote = map_objectclass_convert_remote,
+ },
+ },
+};
+
+
/* Mappings for searches on objectClass= assuming a one-to-one
* mapping. Needed because this is a generate operator for the
* add/modify code */
/* Mappings for searches on objectClass= assuming a one-to-one
* mapping. Needed because this is a generate operator for the
* add/modify code */
struct ldb_parse_tree **new, const struct ldb_parse_tree *tree)
{
struct ldb_parse_tree **new, const struct ldb_parse_tree *tree)
{
- static const struct ldb_map_attribute objectclass_map = {
- .local_name = "objectClass",
- .type = MAP_CONVERT,
- .u = {
- .convert = {
- .remote_name = "objectClass",
- .convert_local = map_objectclass_convert_local,
- .convert_remote = map_objectclass_convert_remote,
- },
- },
- };
-
- return map_subtree_collect_remote_simple(module, mem_ctx, new, tree, &objectclass_map);
+ return map_subtree_collect_remote_simple(module, mem_ctx, new, tree, &objectclass_convert_map);
}
/* Auxiliary request construction
}
/* Auxiliary request construction
- {
- .local_name = "objectClass",
- .type = MAP_GENERATE,
- .convert_operator = map_objectclass_convert_operator,
- .u = {
- .generate = {
- .remote_names = { "objectClass", NULL },
- .generate_local = map_objectclass_generate_local,
- .generate_remote = map_objectclass_generate_remote,
- },
- },
- },
{
.local_name = NULL,
}
};
{
.local_name = NULL,
}
};
+static const struct ldb_map_attribute objectclass_attribute_map = {
+ .local_name = "objectClass",
+ .type = MAP_GENERATE,
+ .convert_operator = map_objectclass_convert_operator,
+ .u = {
+ .generate = {
+ .remote_names = { "objectClass", NULL },
+ .generate_local = map_objectclass_generate_local,
+ .generate_remote = map_objectclass_generate_remote,
+ },
+ },
+};
+
+
/* Find the special 'MAP_DN_NAME' record and store local and remote
* base DNs in private data. */
static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, const char *name)
/* Find the special 'MAP_DN_NAME' record and store local and remote
* base DNs in private data. */
static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, const char *name)
for (j = 0; builtin_attribute_maps[j].local_name; j++) /* noop */ ;
/* Store list of attribute maps */
for (j = 0; builtin_attribute_maps[j].local_name; j++) /* noop */ ;
/* Store list of attribute maps */
- data->attribute_maps = talloc_array(data, struct ldb_map_attribute, i+j+1);
+ data->attribute_maps = talloc_array(data, struct ldb_map_attribute, i+j+2);
if (data->attribute_maps == NULL) {
map_oom(module);
return LDB_ERR_OPERATIONS_ERROR;
if (data->attribute_maps == NULL) {
map_oom(module);
return LDB_ERR_OPERATIONS_ERROR;
+ if (data->add_objectclass) {
+ /* ObjectClass one is very last, if required */
+ data->attribute_maps[last] = objectclass_attribute_map;
+ last++;
+ } else if (ocls) {
+ data->attribute_maps[last] = objectclass_convert_map;
+ last++;
+ }
+
/* Ensure 'local_name == NULL' for the last entry */
memset(&data->attribute_maps[last], 0, sizeof(struct ldb_map_attribute));
/* Ensure 'local_name == NULL' for the last entry */
memset(&data->attribute_maps[last], 0, sizeof(struct ldb_map_attribute));
/* Initialize global private data. */
_PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attrs,
/* Initialize global private data. */
_PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attrs,
- const struct ldb_map_objectclass *ocls,
- const char * const *wildcard_attributes,
- const char *name)
+ const struct ldb_map_objectclass *ocls,
+ const char * const *wildcard_attributes,
+ const char *add_objectclass,
+ const char *name)
{
struct map_private *data;
int ret;
{
struct map_private *data;
int ret;
+ data->context->add_objectclass = add_objectclass;
+
/* Store list of attribute and objectClass maps */
ret = map_init_maps(module, data->context, attrs, ocls, wildcard_attributes);
if (ret != LDB_SUCCESS) {
/* Store list of attribute and objectClass maps */
ret = map_init_maps(module, data->context, attrs, ocls, wildcard_attributes);
if (ret != LDB_SUCCESS) {
* to any wildcard search */
const char * const *wildcard_attributes;
* to any wildcard search */
const char * const *wildcard_attributes;
+ /* ObjectClass (if any) to be added to remote attributes on add */
+ const char *add_objectclass;
+
/* struct ldb_context *mapped_ldb; */
struct ldb_dn *local_base_dn;
struct ldb_dn *remote_base_dn;
/* struct ldb_context *mapped_ldb; */
struct ldb_dn *local_base_dn;
struct ldb_dn *remote_base_dn;
int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attrs,
const struct ldb_map_objectclass *ocls,
const char * const *wildcard_attributes,
int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attrs,
const struct ldb_map_objectclass *ocls,
const char * const *wildcard_attributes,
+ const char *add_objectclass,
const char *name);
/* get copy of map_ops */
const char *name);
/* get copy of map_ops */