From ee524d3182de85dff2febaad2481e37ad5a8be8f Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Mon, 24 May 2010 11:06:29 +0200 Subject: s4:"rdn_name" LDB module - fix the creation of the RDN attribute (try to normalise it) And return always the correct error codes on the failed add operations (should anyway be ERR_OPERATIONS_ERROR - therefore no behaviour change). --- source4/lib/ldb/modules/rdn_name.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index f1c167cc39..3a4068daf2 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -134,19 +134,33 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) attribute->num_values = 0; } - if (ldb_msg_add_value(msg, "name", &rdn_val, NULL) != 0) { + ret = ldb_msg_add_value(msg, "name", &rdn_val, NULL); + if (ret != LDB_SUCCESS) { + return ret; + } + + a = ldb_schema_attribute_by_name(ldb, rdn_name); + if (a == NULL) { return LDB_ERR_OPERATIONS_ERROR; } attribute = rdn_name_find_attribute(msg, rdn_name); - if (!attribute) { - if (ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + /* add entry with normalised RDN information if possible */ + if (a->name != NULL) { + ret = ldb_msg_add_value(msg, a->name, &rdn_val, NULL); + } else { + ret = ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL); + } + if (ret != LDB_SUCCESS) { + return ret; } } else { - a = ldb_schema_attribute_by_name(ldb, rdn_name); - + /* normalise attribute name if possible */ + if (a->name != NULL) { + attribute->name = a->name; + } + /* normalise attribute value */ for (i = 0; i < attribute->num_values; i++) { ret = a->syntax->comparison_fn(ldb, msg, &rdn_val, &attribute->values[i]); -- cgit