break;
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
case LDB_MAP_CONVERT:
if (ldb_attr_cmp(map->u.rename.remote_name, name) == 0) {
return map;
return talloc_strdup(mem_ctx, attr);
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
case LDB_MAP_CONVERT:
return talloc_strdup(mem_ctx, map->u.rename.remote_name);
/* fall through */
case LDB_MAP_KEEP:
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
name = map_attr_map_local(newdn, map, ldb_dn_get_component_name(dn, i));
if (name == NULL) goto failed;
/* fall through */
case LDB_MAP_KEEP:
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
name = map_attr_map_remote(newdn, map, ldb_dn_get_component_name(dn, i));
if (name == NULL) goto failed;
LDB_MAP_KEEP, /* Keep as is. Same name locally and remotely. */
LDB_MAP_RENAME, /* Simply rename the attribute. Name changes, data is the same */
LDB_MAP_CONVERT, /* Rename + convert data */
- LDB_MAP_GENERATE /* Use generate function for generating new name/data.
+ LDB_MAP_GENERATE, /* Use generate function for generating new name/data.
Used for generating attributes based on
multiple remote attributes. */
+ LDB_MAP_RENDROP /* Rename the attribute. Strip from Add requests. */
} type;
/* if set, will be called for search expressions that contain this attribute */
/* Add a message element either to a local or to a remote message,
* depending on whether it goes into the local or remote partition. */
-static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg, const char *attr_name, /* const char * const names[], */ const struct ldb_message_element *old)
+static int ldb_msg_el_partition(struct ldb_module *module, enum ldb_request_type optype, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg, const char *attr_name, /* const char * const names[], */ const struct ldb_message_element *old)
{
const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map = map_attr_find_local(data, attr_name);
}
switch (map->type) {
+ case LDB_MAP_RENDROP:
+ if (optype != LDB_ADD) {
+ /* do the same as LDB_MAP_RENAME */
+ el = ldb_msg_el_map_local(module, remote, map, old);
+ break;
+ }
+ /* fall through */
case LDB_MAP_IGNORE:
goto local;
/* Split message elements that stay in the local partition from those
* that are mapped into the remote partition. */
-static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg)
+static int ldb_msg_partition(struct ldb_module *module, enum ldb_request_type optype, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg)
{
/* const char * const names[]; */
struct ldb_context *ldb;
continue;
}
- ret = ldb_msg_el_partition(module, local, remote, msg, msg->elements[i].name, &msg->elements[i]);
+ ret = ldb_msg_el_partition(module, optype, local, remote, msg, msg->elements[i].name, &msg->elements[i]);
if (ret) {
return ret;
}
remote_msg->dn = ldb_dn_map_local(ac->module, remote_msg, msg->dn);
/* Split local from remote message */
- ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
+ ldb_msg_partition(module, req->operation, ac->local_msg, remote_msg, msg);
/* Prepare the remote operation */
ret = ldb_build_add_req(&ac->remote_req, ldb,
remote_msg->dn = ldb_dn_map_local(ac->module, remote_msg, msg->dn);
/* Split local from remote message */
- ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
+ ldb_msg_partition(module, req->operation, ac->local_msg, remote_msg, msg);
/* Prepare the remote operation */
ret = ldb_build_mod_req(&ac->remote_req, ldb,
goto named;
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
case LDB_MAP_CONVERT:
name = map->u.rename.remote_name;
goto named;
for (i = 0; data->attribute_maps[i].local_name; i++) {
struct ldb_map_attribute *am = &data->attribute_maps[i];
- if ((am->type == LDB_MAP_RENAME &&
+ if (((am->type == LDB_MAP_RENAME || am->type == LDB_MAP_RENDROP) &&
!strcmp(am->u.rename.remote_name, attr_name))
|| (am->type == LDB_MAP_CONVERT &&
!strcmp(am->u.convert.remote_name, attr_name))) {
remote_name = attr_name;
break;
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
remote_name = map->u.rename.remote_name;
break;
case LDB_MAP_GENERATE:
/* fall through */
case LDB_MAP_KEEP:
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
old = ldb_msg_find_element(remote, remote_name);
if (old) {
el = ldb_msg_el_map_remote(module, local, map, attr_name, old);
return 0;
}
- if (map->type == LDB_MAP_RENAME) {
+ if (map->type == LDB_MAP_RENAME || map->type == LDB_MAP_RENDROP) {
/* Nothing more to do here, the attribute has been renamed */
return 0;
}