s4-dsdb: Improve logging for drs_ObjectIdentifier_to_dn_and_nc_root()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 27 Jun 2023 02:59:49 +0000 (14:59 +1200)
committerJule Anger <janger@samba.org>
Mon, 21 Aug 2023 07:40:16 +0000 (07:40 +0000)
At this layer we can make a reasonable assumption about being able
to read ldb_errstring() to print that for extra useful debugging.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15401

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 63843a22c8db73d459bee61e73bb1f0d31e3d427)

source4/dsdb/common/dsdb_dn.c

index c86848fd69758ddcce53fc4c732e8d8816301cb8..b34d1e6052a390c721e1b5637363d980430d73d7 100644 (file)
@@ -554,6 +554,18 @@ int drs_ObjectIdentifier_to_dn_and_nc_root(TALLOC_CTX *mem_ctx,
                                                 new_dn,
                                                 normalised_dn,
                                                 nc_root);
+       if (ret != LDB_SUCCESS) {
+               /*
+                * dsdb_normalise_dn_and_find_nc_root() sets LDB error
+                * strings, and the functions it calls do also
+                */
+               DBG_NOTICE("Failed to find DN \"%s\" -> \"%s\" for normalisation: %s (%s)\n",
+                          drs_ObjectIdentifier_to_debug_string(mem_ctx, nc),
+                          ldb_dn_get_extended_linearized(mem_ctx, new_dn, 1),
+                          ldb_errstring(ldb),
+                          ldb_strerror(ret));
+       }
+
        TALLOC_FREE(new_dn);
        return ret;
 }