[PATCH] samdb: Enable del/add style mods to "description"

Volker Lendecke vl at samba.org
Sun Feb 13 08:52:02 MST 2011


---
 source4/dsdb/samdb/ldb_modules/samldb.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index ee0d66c..bf12e62 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -1580,6 +1580,7 @@ static int samldb_description_check(struct samldb_ctx *ac)
 	struct ldb_result *res;
 	unsigned int i;
 	int ret;
+	bool description_exists;
 
 	/* Fetch informations from the existing object */
 
@@ -1605,6 +1606,9 @@ static int samldb_description_check(struct samldb_ctx *ac)
 		return LDB_SUCCESS;
 	}
 
+	description_exists =
+		ldb_msg_find_element(res->msgs[0], "description") != NULL;
+
 	/* We've to walk over all modification entries and consider the
 	 * "description" ones. */
 	for (i = 0; i < ac->msg->num_elements; i++) {
@@ -1624,15 +1628,20 @@ static int samldb_description_check(struct samldb_ctx *ac)
 			return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
 		}
 
+		if (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_DELETE) {
+			description_exists = false;
+		}
+
 		/* Add operations are only allowed if no value exists */
-		if (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_ADD) {
-			if (ldb_msg_find_element(res->msgs[0], "description")
-								!= NULL) {
-				ldb_asprintf_errstring(ldb,
-						       "samldb: Description on SAM entry '%s' is changed using an add operation while a value already exists!",
-						       ldb_dn_get_linearized(ac->msg->dn));
-				return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
-			}
+		if ((LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_ADD)
+		    && description_exists) {
+			ldb_asprintf_errstring(
+				ldb,
+				"samldb: Description on SAM entry '%s' is "
+				"changed using an add operation while a "
+				"value already exists!",
+				ldb_dn_get_linearized(ac->msg->dn));
+			return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
 		}
 	}
 
-- 
1.7.0.4


--h31gzZEtNLTqOjlF--


More information about the samba-technical mailing list