From ce20796be2e7259943afa203a2f1a471eaa6776a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Jul 2006 03:00:16 +0000 Subject: r17304: Improve ldb_tdb error strings a bit more. Andrew Bartlett (This used to be commit 38bd4f61794e5a664822240d77c1e1c61abc7c44) --- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 1401052955..cbc9d61613 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -271,6 +271,25 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message ret = ltdb_store(module, msg, TDB_INSERT); if (ret != LDB_SUCCESS) { + switch (ret) { + case LDB_ERR_ENTRY_ALREADY_EXISTS: + { + TALLOC_CTX *mem_ctx = talloc_new(module); + char *errstring, *dn; + if (!mem_ctx) { + break; + } + dn = ldb_dn_linearize(mem_ctx, msg->dn); + if (!dn) { + break; + } + errstring = talloc_asprintf(mem_ctx, "Entry %s already exists", + dn); + ldb_set_errstring(module->ldb, errstring); + talloc_free(mem_ctx); + break; + } + } return ret; } @@ -694,7 +713,8 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms if (msg->elements[i].num_values == 0) { if (msg_delete_attribute(module, ldb, msg2, msg->elements[i].name) != 0) { - err_string = talloc_asprintf(module, "No such attribute: %s", msg->elements[i].name); + err_string = talloc_asprintf(module, "No such attribute: %s for delete on %s", + msg->elements[i].name, dn); if (err_string) ldb_set_errstring(module->ldb, err_string); ret = LDB_ERR_NO_SUCH_ATTRIBUTE; goto failed; @@ -706,7 +726,8 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms msg2, msg->elements[i].name, &msg->elements[i].values[j]) != 0) { - err_string = talloc_asprintf(module, "No such attribute: %s", msg->elements[i].name); + err_string = talloc_asprintf(module, "No matching attribute value when deleting attribute: %s on %s", + msg->elements[i].name, dn); if (err_string) ldb_set_errstring(module->ldb, err_string); ret = LDB_ERR_NO_SUCH_ATTRIBUTE; goto failed; -- cgit