provision: setup names.dns_backend
authorStefan Metzmacher <metze@samba.org>
Fri, 25 Jan 2013 08:36:47 +0000 (09:36 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 27 Jan 2013 09:14:22 +0000 (20:14 +1100)
If we have a DomainDnsZone partition:
 - we use BIND9_DLZ as backend if a dns-<netbiosname> account is available
 - otherwise, we use SAMBA_INTERNAL
else:
 - we use BIND9_FLATFILE if a dns or dns-<netbiosname> account is available
 - otherwise, we use NONE

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/python/samba/provision/__init__.py

index 8f4928ce2b13403a124305f347f3d031f720c521..507582bad590f492cc332a0a6166015d33a2cc63 100644 (file)
@@ -291,6 +291,32 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
     else:
         names.root_gid = pwd.getpwuid(int(res9[0]["xidNumber"][0])).pw_gid
 
+    res10 = samdb.search(expression="(samaccountname=dns)",
+                         scope=ldb.SCOPE_SUBTREE, attrs=["dn"],
+                         controls=["search_options:1:2"])
+    if (len(res10) > 0):
+        has_legacy_dns_account = True
+    else:
+        has_legacy_dns_account = False
+
+    res11 = samdb.search(expression="(samaccountname=dns-%s)" % names.netbiosname,
+                         scope=ldb.SCOPE_SUBTREE, attrs=["dn"],
+                         controls=["search_options:1:2"])
+    if (len(res11) > 0):
+        has_dns_account = True
+    else:
+        has_dns_account = False
+
+    if names.dnsdomaindn is not None:
+        if has_dns_account:
+            names.dns_backend = 'BIND9_DLZ'
+        else:
+            names.dns_backend = 'SAMBA_INTERNAL'
+    elif has_dns_account or has_legacy_dns_account:
+        names.dns_backend = 'BIND9_FLATFILE'
+    else:
+        names.dns_backend = 'NONE'
+
     dns_admins_sid = get_dnsadmins_sid(samdb, names.domaindn)
     names.name_map['DnsAdmins'] = str(dns_admins_sid)