s4:samldb: improve error strings
authorAndrew Bartlett <abartlet@samba.org>
Tue, 16 Dec 2008 07:40:49 +0000 (08:40 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 17 Dec 2008 01:29:25 +0000 (12:29 +1100)
When things go wrong with LDB, this routine seems to be particularly
sensitive to it.  This extra debugging should help the next poor soul who
breaks LDB.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source4/dsdb/samdb/ldb_modules/samldb.c

index 95a16b5527ee01eed06b1b0b877d41d1c4797633..627e15ab93dc2d50ed2e250a84137c6b153a6e1c 100644 (file)
@@ -346,13 +346,14 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req,
                }
 
                nextRid = ldb_msg_find_attr_as_string(ares->message,
                }
 
                nextRid = ldb_msg_find_attr_as_string(ares->message,
-                                                       "nextRid", NULL);
+                                                     "nextRid", NULL);
                if (nextRid == NULL) {
                        ldb_asprintf_errstring(ac->module->ldb,
                if (nextRid == NULL) {
                        ldb_asprintf_errstring(ac->module->ldb,
-                               "attribute nextRid not found in %s\n",
-                               ldb_dn_get_linearized(ares->message->dn));
+                               "while looking for domain above %s attribute nextRid not found in %s\n",
+                                              ldb_dn_get_linearized(ac->req->op.add.message->dn), 
+                                              ldb_dn_get_linearized(ares->message->dn));
                        ret = LDB_ERR_OPERATIONS_ERROR;
                        ret = LDB_ERR_OPERATIONS_ERROR;
-                       break;;
+                       break;
                }
 
                ac->next_rid = strtol(nextRid, NULL, 0);
                }
 
                ac->next_rid = strtol(nextRid, NULL, 0);
@@ -369,6 +370,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req,
 
                talloc_free(ares);
                ret = LDB_SUCCESS;
 
                talloc_free(ares);
                ret = LDB_SUCCESS;
+               ldb_reset_err_string(ac->module->ldb);
                break;
 
        case LDB_REPLY_REFERRAL:
                break;
 
        case LDB_REPLY_REFERRAL:
@@ -1067,8 +1069,8 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req,
                                                        "nextRid", NULL);
                if (nextRid == NULL) {
                        ldb_asprintf_errstring(ac->module->ldb,
                                                        "nextRid", NULL);
                if (nextRid == NULL) {
                        ldb_asprintf_errstring(ac->module->ldb,
-                               "attribute nextRid not found in %s\n",
-                               ldb_dn_get_linearized(ares->message->dn));
+                               "while looking for forign sid %s attribute nextRid not found in %s\n",
+                                              dom_sid_string(ares, ac->sid), ldb_dn_get_linearized(ares->message->dn));
                        ret = LDB_ERR_OPERATIONS_ERROR;
                        break;
                }
                        ret = LDB_ERR_OPERATIONS_ERROR;
                        break;
                }