From: Stefan Metzmacher Date: Tue, 11 Feb 2025 15:09:53 +0000 (+0100) Subject: s4:dsdb/common: add dsdb_trust_default_forest_info() X-Git-Tag: tevent-0.17.0~710 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04a496cd220a1304c2a73aad7521edb4b2e22077;p=thirdparty%2Fsamba.git s4:dsdb/common: add dsdb_trust_default_forest_info() Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source4/dsdb/common/util_trusts.c b/source4/dsdb/common/util_trusts.c index ab1fb26b810..0d1a8d63874 100644 --- a/source4/dsdb/common/util_trusts.c +++ b/source4/dsdb/common/util_trusts.c @@ -804,6 +804,64 @@ NTSTATUS dsdb_trust_parse_forest_info(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +NTSTATUS dsdb_trust_default_forest_info(TALLOC_CTX *mem_ctx, + const struct dom_sid *sid, + const char *dns_name, + const char *nbt_name, + NTTIME now, + struct ForestTrustInfo **_fti) +{ + struct ForestTrustInfo *trust_fti = NULL; + struct ForestTrustInfoRecordArmor *ra = NULL; + struct ForestTrustInfoRecord *r = NULL; + + trust_fti = talloc_zero(mem_ctx, struct ForestTrustInfo); + if (trust_fti == NULL) { + return NT_STATUS_NO_MEMORY; + } + + ra = talloc_zero_array(trust_fti, + struct ForestTrustInfoRecordArmor, + 2); + if (ra == NULL) { + TALLOC_FREE(trust_fti); + return NT_STATUS_NO_MEMORY; + } + + r = &ra[0].record; + r->type = FOREST_TRUST_TOP_LEVEL_NAME; + r->timestamp = now; + r->flags = 0; + r->data.name.string = talloc_strdup(ra, dns_name); + if (r->data.name.string == NULL) { + TALLOC_FREE(trust_fti); + return NT_STATUS_NO_MEMORY; + } + + r = &ra[1].record; + r->type = FOREST_TRUST_DOMAIN_INFO; + r->timestamp = now; + r->flags = 0; + r->data.info.sid = *sid; + r->data.info.dns_name.string = talloc_strdup(ra, dns_name); + if (r->data.info.dns_name.string == NULL) { + TALLOC_FREE(trust_fti); + return NT_STATUS_NO_MEMORY; + } + r->data.info.netbios_name.string = talloc_strdup(ra, nbt_name); + if (r->data.info.netbios_name.string == NULL) { + TALLOC_FREE(trust_fti); + return NT_STATUS_NO_MEMORY; + } + + trust_fti->version = 1; + trust_fti->records = ra; + trust_fti->count = 2; + + *_fti = trust_fti; + return NT_STATUS_OK; +} + NTSTATUS dsdb_trust_normalize_forest_info_step1(TALLOC_CTX *mem_ctx, const struct lsa_ForestTrustInformation *gfti, struct lsa_ForestTrustInformation **_nfti)