provision: setup names.dns_backend
authorStefan Metzmacher <metze@samba.org>
Fri, 25 Jan 2013 08:36:47 +0000 (09:36 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 28 Jan 2013 10:07:23 +0000 (11:07 +0100)
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>
(cherry picked from commit b855df254de40d9de0b7f9042564f6d521ab1c5d)

source4/scripting/python/samba/provision/__init__.py

index f5d8451326aeb153b9817f9cf7a4671a250725b3..3c878e9a6eb713496ae9bd390776221d7d0ca1aa 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)