s4: samba_spnupdate: fix "if we are DNS server" check
[kai/samba.git] / source4 / scripting / bin / samba_spnupdate
index 69406a8196bdfe688340a1a4368530b9a92c9a3f..977de68bc2c35930ec86a01897e88fbe3e7f47de 100755 (executable)
@@ -130,11 +130,12 @@ res = samdb.search(base=samdb.get_config_basedn(),
 
 basedn = str(samdb.get_default_basedn())
 if len(res) == 1:
-    for e in res[0]["msDS-hasMasterNCs"]:
-        if str(e) == "DC=DomainDnsZones,%s" % basedn:
-            has_domain_dns = True
-        if str(e) == "DC=ForestDnsZones,%s" % basedn:
-            has_forest_dns = True
+    if "msDS-hasMasterNCs" in res[0]:
+        for e in res[0]["msDS-hasMasterNCs"]:
+            if str(e) == "DC=DomainDnsZones,%s" % basedn:
+                has_domain_dns = True
+            if str(e) == "DC=ForestDnsZones,%s" % basedn:
+                has_forest_dns = True
 
 
 # build the spn list