diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-05-24 11:06:29 +0200 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-05-24 14:01:06 +0200 |
commit | ee524d3182de85dff2febaad2481e37ad5a8be8f (patch) | |
tree | f75723aa38c3f2fe630aef5f453b6104c21108de /source4 | |
parent | 40ced1a3be5ab04c7431ecda2c7924336a852994 (diff) | |
download | samba-ee524d3182de85dff2febaad2481e37ad5a8be8f.tar.gz samba-ee524d3182de85dff2febaad2481e37ad5a8be8f.tar.bz2 samba-ee524d3182de85dff2febaad2481e37ad5a8be8f.zip |
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).
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/modules/rdn_name.c | 26 |
1 files 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]); |