r17304: Improve ldb_tdb error strings a bit more.
authorAndrew Bartlett <abartlet@samba.org>
Sat, 29 Jul 2006 03:00:16 +0000 (03:00 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:15:09 +0000 (14:15 -0500)
Andrew Bartlett
(This used to be commit 38bd4f61794e5a664822240d77c1e1c61abc7c44)

source4/lib/ldb/ldb_tdb/ldb_tdb.c

index 1401052955a3b6a2272e0e8a7c8d2cf87ea754da..cbc9d616132fec18c08ed6c7dd3f6b27f6ce3a99 100644 (file)
@@ -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;