From 607d7c5cdfc6575ac24df7c8996c11c9679abb44 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 24 Aug 2011 15:32:57 +1000 Subject: s4-provision Use samba.dns_name_to_dn --- source4/scripting/python/samba/__init__.py | 4 ++++ source4/scripting/python/samba/provision/__init__.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index 76eb44ce92..03ee6faa59 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -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 diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index 50dff9d086..1799663137 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -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)) -- cgit