From 8e10c10bd6e601df47a2815c638482e486646f59 Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Fri, 7 Nov 2014 07:02:51 +0100 Subject: [PATCH] s4-dsdb-util: Mark attributes with ADD flag in samdb_find_or_add_attribute() At the moment no flags are set and it works fine, since this function is solely used in samldb during ADD requests handling. Pre-setting a flag make it usefull for other modules and request handlers too Change-Id: I7e43dcbe2a8f34e3b0ec16ae2db80ef436df8bfe Signed-off-by: Kamen Mazdrashki Reviewed-by: Andrew Bartlett Reviewed-by: Garming Sam --- source4/dsdb/common/util.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 504afd8b777..6c05b5081a4 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -774,6 +774,7 @@ struct ldb_message_element *samdb_find_attribute(struct ldb_context *ldb, int samdb_find_or_add_attribute(struct ldb_context *ldb, struct ldb_message *msg, const char *name, const char *set_value) { + int ret; struct ldb_message_element *el; el = ldb_msg_find_element(msg, name); @@ -781,7 +782,12 @@ int samdb_find_or_add_attribute(struct ldb_context *ldb, struct ldb_message *msg return LDB_SUCCESS; } - return ldb_msg_add_string(msg, name, set_value); + ret = ldb_msg_add_string(msg, name, set_value); + if (ret != LDB_SUCCESS) { + return ret; + } + msg->elements[msg->num_elements - 1].flags = LDB_FLAG_MOD_ADD; + return LDB_SUCCESS; } /* -- 2.11.4.GIT