s4-dsdb: Added a helper function to get the default dns domain as string.
authorNadezhda Ivanova <nivanova@samba.org>
Wed, 22 Dec 2010 10:19:46 +0000 (12:19 +0200)
committerNadezhda Ivanova <nivanova@samba.org>
Wed, 22 Dec 2010 10:29:14 +0000 (12:29 +0200)
source4/dsdb/common/util.c

index 36f69337a65861148665b7b035370b3d60810d3c..b2d4be00689c0a15b2f397b381aa6743ef6131ac 100644 (file)
@@ -3952,6 +3952,25 @@ const char *samdb_forest_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx)
        return forest_name;
 }
 
+/* returns back the default domain DNS name */
+const char *samdb_default_domain_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx)
+{
+       const char *domain_name = ldb_dn_canonical_string(mem_ctx,
+                                                         ldb_get_default_basedn(ldb));
+       char *p;
+
+       if (domain_name == NULL) {
+               return NULL;
+       }
+
+       p = strchr(domain_name, '/');
+       if (p) {
+               *p = '\0';
+       }
+
+       return domain_name;
+}
+
 /*
    validate that an DSA GUID belongs to the specified user sid.
    The user SID must be a domain controller account (either RODC or