From 9f404b3dea7bd34890eb66ff60432e05efdc2f09 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 22 Aug 2011 17:00:54 +1000 Subject: s4-dsdb: added samdb_dn_to_dns_domain() this converts a DC into the equivalent DNS domain. It is used when forming t_msdcs NTDS DNS names Pair-Programmed-With: Amitay Isaacs --- source4/dsdb/common/util.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'source4/dsdb/common/util.c') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index ac380e9db6..cf2e766f01 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -2354,6 +2354,42 @@ struct ldb_dn *samdb_dns_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_c return dn; } + +/* + Find the DNS equivalent of a DN, in dotted DNS form +*/ +char *samdb_dn_to_dns_domain(TALLOC_CTX *mem_ctx, struct ldb_dn *dn) +{ + int i, num_components = ldb_dn_get_comp_num(dn); + char *dns_name = talloc_strdup(mem_ctx, ""); + if (dns_name == NULL) { + return NULL; + } + + for (i=0; ilength, v->length, (char *)v->data); + if (s == NULL) { + talloc_free(dns_name); + return NULL; + } + dns_name = s; + } + + /* remove the last '.' */ + if (dns_name[0] != 0) { + dns_name[strlen(dns_name)-1] = 0; + } + + return dns_name; +} + + /* Find the DN of a domain, be it the netbios or DNS name */ -- cgit