a helper function to a DN element to an ldb_msg using ldb_msg_add_string.
Signed-off-by: Andrew Tridgell <tridge@samba.org>
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);
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
*/
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);
struct ldb_context *ldb;
struct map_context *ac;
struct ldb_message *remote_msg;
- const char *dn;
int ret;
ldb = ldb_module_get_ctx(module);
/* 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;
}
{
struct ldb_request *local_req;
struct ldb_context *ldb;
- char *dn;
int ret;
ldb = ldb_module_get_ctx(ac->module);
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;
}