added new function "ldb_msg_add_dn"
[samba.git] / source4 / lib / ldb / ldb_map / ldb_map_inbound.c
index e915a5f46a38fe073c51f37010ca8dddd896917b..11ec9d2ceda12d98ec6c2d6f62211c707e95b3dc 100644 (file)
@@ -24,8 +24,7 @@
 
 */
 
-#include "ldb_module.h"
-
+#include "ldb_includes.h"
 #include "ldb_map.h"
 #include "ldb_map_private.h"
 
@@ -74,34 +73,34 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l
        /* Unknown attribute: ignore */
        if (map == NULL) {
                ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
-                         "Not mapping attribute '%s': no mapping found\n",
+                         "Not mapping attribute '%s': no mapping found",
                          old->name);
                goto local;
        }
 
        switch (map->type) {
-       case MAP_IGNORE:
+       case LDB_MAP_IGNORE:
                goto local;
 
-       case MAP_CONVERT:
+       case LDB_MAP_CONVERT:
                if (map->u.convert.convert_local == NULL) {
                        ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
                                  "Not mapping attribute '%s': "
-                                 "'convert_local' not set\n",
+                                 "'convert_local' not set",
                                  map->local_name);
                        goto local;
                }
                /* fall through */
-       case MAP_KEEP:
-       case MAP_RENAME:
+       case LDB_MAP_KEEP:
+       case LDB_MAP_RENAME:
                el = ldb_msg_el_map_local(module, remote, map, old);
                break;
 
-       case MAP_GENERATE:
+       case LDB_MAP_GENERATE:
                if (map->u.generate.generate_remote == NULL) {
                        ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
                                  "Not mapping attribute '%s': "
-                                 "'generate_remote' not set\n",
+                                 "'generate_remote' not set",
                                  map->local_name);
                        goto local;
                }
@@ -168,7 +167,7 @@ static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *loca
                /* Skip 'IS_MAPPED' */
                if (ldb_attr_cmp(msg->elements[i].name, IS_MAPPED) == 0) {
                        ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
-                                 "Skipping attribute '%s'\n",
+                                 "Skipping attribute '%s'",
                                  msg->elements[i].name);
                        continue;
                }
@@ -363,7 +362,6 @@ int map_add(struct ldb_module *module, struct ldb_request *req)
        struct ldb_context *ldb;
        struct map_context *ac;
        struct ldb_message *remote_msg;
-       const char *dn;
        int ret;
 
        ldb = ldb_module_get_ctx(module);
@@ -427,8 +425,7 @@ int map_add(struct ldb_module *module, struct ldb_request *req)
 
        /* Store remote DN in 'IS_MAPPED' */
        /* TODO: use GUIDs here instead */
-       dn = ldb_dn_alloc_linearized(ac->local_msg, remote_msg->dn);
-       if (ldb_msg_add_string(ac->local_msg, IS_MAPPED, dn) != 0) {
+       if (ldb_msg_add_dn(ac->local_msg, IS_MAPPED, remote_msg->dn) != 0) {
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
@@ -546,7 +543,6 @@ static int map_modify_do_local(struct map_context *ac)
 {
        struct ldb_request *local_req;
        struct ldb_context *ldb;
-       char *dn;
        int ret;
 
        ldb = ldb_module_get_ctx(ac->module);
@@ -559,9 +555,8 @@ static int map_modify_do_local(struct map_context *ac)
                                        LDB_FLAG_MOD_ADD, NULL) != 0) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
-               dn = ldb_dn_alloc_linearized(ac->local_msg,
-                                       ac->remote_req->op.mod.message->dn);
-               if (ldb_msg_add_string(ac->local_msg, IS_MAPPED, dn) != 0) {
+               if (ldb_msg_add_dn(ac->local_msg, IS_MAPPED,
+                                  ac->remote_req->op.mod.message->dn) != 0) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }