dsdb: Use samdb_system_container_dn() in dsdb_trust_*()
authorAndrew Bartlett <abartlet@samba.org>
Thu, 27 Jul 2023 05:14:30 +0000 (17:14 +1200)
committerJule Anger <janger@samba.org>
Tue, 1 Aug 2023 09:53:17 +0000 (09:53 +0000)
This is now exactly the same actions, but just uses common code to do it.

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

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

source4/dsdb/common/util_trusts.c

index 0f4d5584192edc4357370b3402607892ad7ef7d4..fd1aa2be4d40f68e36b4e7fc121a1d902d9ed4e8 100644 (file)
@@ -2459,17 +2459,12 @@ NTSTATUS dsdb_trust_search_tdo(struct ldb_context *sam_ctx,
                return NT_STATUS_INVALID_PARAMETER_MIX;
        }
 
-       system_dn = ldb_dn_copy(frame, ldb_get_default_basedn(sam_ctx));
+       system_dn = samdb_system_container_dn(sam_ctx, frame);
        if (system_dn == NULL) {
                TALLOC_FREE(frame);
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!ldb_dn_add_child_fmt(system_dn, "CN=System")) {
-               TALLOC_FREE(frame);
-               return NT_STATUS_NO_MEMORY;
-       }
-
        if (netbios != NULL) {
                netbios_encoded = ldb_binary_encode_string(frame, netbios);
                if (netbios_encoded == NULL) {
@@ -2617,17 +2612,12 @@ NTSTATUS dsdb_trust_search_tdo_by_sid(struct ldb_context *sam_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       system_dn = ldb_dn_copy(frame, ldb_get_default_basedn(sam_ctx));
+       system_dn = samdb_system_container_dn(sam_ctx, frame);
        if (system_dn == NULL) {
                TALLOC_FREE(frame);
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!ldb_dn_add_child_fmt(system_dn, "CN=System")) {
-               TALLOC_FREE(frame);
-               return NT_STATUS_NO_MEMORY;
-       }
-
        filter = talloc_asprintf(frame,
                                "(&"
                                  "(objectClass=trustedDomain)"
@@ -2794,17 +2784,12 @@ NTSTATUS dsdb_trust_search_tdos(struct ldb_context *sam_ctx,
 
        *res = NULL;
 
-       system_dn = ldb_dn_copy(frame, ldb_get_default_basedn(sam_ctx));
+       system_dn = samdb_system_container_dn(sam_ctx, frame);
        if (system_dn == NULL) {
                TALLOC_FREE(frame);
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!ldb_dn_add_child_fmt(system_dn, "CN=System")) {
-               TALLOC_FREE(frame);
-               return NT_STATUS_NO_MEMORY;
-       }
-
        if (exclude != NULL) {
                exclude_encoded = ldb_binary_encode_string(frame, exclude);
                if (exclude_encoded == NULL) {