From: Andrew Bartlett Date: Thu, 27 Jul 2023 04:12:11 +0000 (+1200) Subject: dsdb: Add new function samdb_system_container_dn() X-Git-Tag: samba-4.19.0rc2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37094ba8e53b157dfc5571c88eaf25cb8c619bce;p=thirdparty%2Fsamba.git 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) --- diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index fbc8ffe5ce5..5fa9f65e247 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -1276,6 +1276,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;