summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c9
-rw-r--r--source4/lib/ldb/include/ldb.h2
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_inbound.c10
3 files changed, 14 insertions, 7 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 161a6b1f38..375751262f 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -259,6 +259,15 @@ int ldb_msg_add_steal_string(struct ldb_message *msg,
}
/*
+ 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
*/
int ldb_msg_add_fmt(struct ldb_message *msg,
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 2d42596ec6..1d0b533a33 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -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);
+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);
diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
index 5a237ef28c..11ec9d2ced 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
@@ -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;
- const char *dn;
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 */
- 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;
}
@@ -545,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);
@@ -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;
}
- 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;
}