added new function "ldb_msg_add_dn"
authorCrístian Deives <cristiandeives@gmail.com>
Thu, 19 Nov 2009 18:03:59 +0000 (16:03 -0200)
committerAndrew Tridgell <tridge@samba.org>
Fri, 20 Nov 2009 03:39:01 +0000 (14:39 +1100)
a helper function to a DN element to an ldb_msg using ldb_msg_add_string.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/dsdb/samdb/ldb_modules/extended_dn_out.c
source4/lib/ldb/common/ldb_msg.c
source4/lib/ldb/include/ldb.h
source4/lib/ldb/ldb_map/ldb_map_inbound.c

index a3e4f57f4bc369f920b76346cc4e3864b7224ddc..1249a9cdfa8dae065f120b9ef6f83f019a5814d7 100644 (file)
@@ -377,8 +377,9 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
                                ret = ldb_msg_add_steal_string(ares->message, "distinguishedName", 
                                                               ldb_dn_get_extended_linearized(ares->message, ares->message->dn, ac->extended_type));
                        } else {
                                ret = ldb_msg_add_steal_string(ares->message, "distinguishedName", 
                                                               ldb_dn_get_extended_linearized(ares->message, ares->message->dn, ac->extended_type));
                        } else {
-                               ret = ldb_msg_add_string(ares->message, "distinguishedName", 
-                                                        ldb_dn_get_linearized(ares->message->dn));
+                               ret = ldb_msg_add_dn(ares->message,
+                                                    "distinguishedName",
+                                                    ares->message->dn);
                        }
                        if (ret != LDB_SUCCESS) {
                                ldb_oom(ldb);
                        }
                        if (ret != LDB_SUCCESS) {
                                ldb_oom(ldb);
index 161a6b1f38334ce80e44bda0baa0784cb2261191..375751262f56e31fa4f9521ba146720473d4dbc3 100644 (file)
@@ -258,6 +258,15 @@ int ldb_msg_add_steal_string(struct ldb_message *msg,
        return ldb_msg_add_steal_value(msg, attr_name, &val);
 }
 
        return ldb_msg_add_steal_value(msg, attr_name, &val);
 }
 
+/*
+  add a DN element to a message
+*/
+int ldb_msg_add_dn(struct ldb_message *msg, const char *attr_name,
+                  struct ldb_dn *dn)
+{
+       return ldb_msg_add_string(msg, attr_name, ldb_dn_get_linearized(dn));
+}
+
 /*
   add a printf formatted element to a message
 */
 /*
   add a printf formatted element to a message
 */
index 2d42596ec6c115de2a89d38e74ef29bd66e8b0ec..1d0b533a332974b496f3c2fe3d6271d067238b49 100644 (file)
@@ -1752,6 +1752,8 @@ int ldb_msg_add_steal_string(struct ldb_message *msg,
                             const char *attr_name, char *str);
 int ldb_msg_add_string(struct ldb_message *msg, 
                       const char *attr_name, const char *str);
                             const char *attr_name, char *str);
 int ldb_msg_add_string(struct ldb_message *msg, 
                       const char *attr_name, const char *str);
+int ldb_msg_add_dn(struct ldb_message *msg, const char *attr_name,
+                  struct ldb_dn *dn);
 int ldb_msg_add_fmt(struct ldb_message *msg, 
                    const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
 
 int ldb_msg_add_fmt(struct ldb_message *msg, 
                    const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
 
index 5a237ef28cd8249b33b2238f0cca16d87837de5f..11ec9d2ceda12d98ec6c2d6f62211c707e95b3dc 100644 (file)
@@ -362,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;
        struct ldb_context *ldb;
        struct map_context *ac;
        struct ldb_message *remote_msg;
-       const char *dn;
        int ret;
 
        ldb = ldb_module_get_ctx(module);
        int ret;
 
        ldb = ldb_module_get_ctx(module);
@@ -426,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 */
 
        /* 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;
        }
 
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
@@ -545,7 +543,6 @@ static int map_modify_do_local(struct map_context *ac)
 {
        struct ldb_request *local_req;
        struct ldb_context *ldb;
 {
        struct ldb_request *local_req;
        struct ldb_context *ldb;
-       char *dn;
        int ret;
 
        ldb = ldb_module_get_ctx(ac->module);
        int ret;
 
        ldb = ldb_module_get_ctx(ac->module);
@@ -558,9 +555,8 @@ static int map_modify_do_local(struct map_context *ac)
                                        LDB_FLAG_MOD_ADD, NULL) != 0) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
                                        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;
                }
 
                        return LDB_ERR_OPERATIONS_ERROR;
                }