From bac861ed27fb4dc49a6defa3e26f0ea29b6dda4f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 27 Jul 2023 16:12:11 +1200 Subject: [PATCH] dsdb: Add new function samdb_system_container_dn() This will replace many calls crafting or searching for this DN elsewhere in the code. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9959 Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Andrew Bartlett Signed-off-by: Stefan Metzmacher (cherry picked from commit 25b0e1102e1a502152d2695aeddf7c65555b16fb) --- source4/dsdb/common/util.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 39b29cd2a0c..59d1f7eba58 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -1241,6 +1241,25 @@ struct ldb_dn *samdb_infrastructure_dn(struct ldb_context *sam_ctx, TALLOC_CTX * return new_dn; } +struct ldb_dn *samdb_system_container_dn(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx) +{ + struct ldb_dn *new_dn = NULL; + bool ok; + + new_dn = ldb_dn_copy(mem_ctx, ldb_get_default_basedn(sam_ctx)); + if (new_dn == NULL) { + return NULL; + } + + ok = ldb_dn_add_child_fmt(new_dn, "CN=System"); + if (!ok) { + TALLOC_FREE(new_dn); + return NULL; + } + + return new_dn; +} + struct ldb_dn *samdb_sites_dn(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx) { struct ldb_dn *new_dn; -- 2.47.2