From dc74e3e94704ce4a28a0adb8102f71abb723fae1 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 27 Jul 2023 17:14:30 +1200 Subject: [PATCH] dsdb: Use samdb_system_container_dn() in dsdb_trust_*() 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 Reviewed-by: Stefan Metzmacher (cherry picked from commit 4250d07e4dcd43bf7450b1ae603ff46fdc892d02) --- source4/dsdb/common/util_trusts.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/source4/dsdb/common/util_trusts.c b/source4/dsdb/common/util_trusts.c index 0f4d5584192..fd1aa2be4d4 100644 --- a/source4/dsdb/common/util_trusts.c +++ b/source4/dsdb/common/util_trusts.c @@ -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) { -- 2.47.2