s4-provision Use samba.dns_name_to_dn
authorAndrew Bartlett <abartlet@samba.org>
Wed, 24 Aug 2011 05:32:57 +0000 (15:32 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 26 Aug 2011 12:06:07 +0000 (14:06 +0200)
source4/scripting/python/samba/__init__.py
source4/scripting/python/samba/provision/__init__.py

index 76eb44ce928650cbb39b8e1062d107b845b5d356..03ee6faa59f4b80cb9725e28f98e28a12964e2ef 100644 (file)
@@ -339,6 +339,10 @@ def ensure_external_module(modulename, location):
         import_bundled_package(modulename, location)
 
 
+def dn_from_dns_name(dnsdomain):
+    """return a DN from a DNS name domain/forest root"""
+    return "DC=" + ",DC=".join(dnsdomain.split("."))
+
 from samba import _glue
 version = _glue.version
 interface_ips = _glue.interface_ips
index 50dff9d08672ce720995f04cc8acbbbfe0fa97c8..179966313746757f924198f15e7a411821e0e285 100644 (file)
@@ -225,8 +225,8 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, lp)
     # NT domain, kerberos realm, root dn, domain dn, domain dns name
     names.domain = string.upper(lp.get("workgroup"))
     names.realm = lp.get("realm")
-    basedn = "DC=" + names.realm.replace(".",",DC=")
     names.dnsdomain = names.realm.lower()
+    basedn = samba.dn_from_dns_name(names.dnsdomain)
     names.realm = string.upper(names.realm)
     # netbiosname
     # Get the netbiosname first (could be obtained from smb.conf in theory)
@@ -619,7 +619,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
             raise ProvisioningError("guess_names: Workgroup '%s' in smb.conf must match chosen domain '%s'!  Please remove the %s file and let provision generate it" % (lp.get("workgroup").upper(), domain, lp.configfile))
 
         if domaindn is None:
-            domaindn = "DC=" + dnsdomain.replace(".", ",DC=")
+            domaindn = samba.dn_from_dns_name(dnsdomain)
 
         if domain == netbiosname:
             raise ProvisioningError("guess_names: Domain '%s' must not be equal to short host name '%s'!" % (domain, netbiosname))