s4:domainlevel.py - update the script to handle both domain level occourrences on s4
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 13 May 2010 13:29:20 +0000 (15:29 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 13 May 2010 13:33:11 +0000 (15:33 +0200)
The second "modify" is located under a try-catch block to ignore the change
failure against Windows Server (there only the first change is required).

source4/scripting/python/samba/netcmd/domainlevel.py

index f7e67a2eda552e59f5bb2494b5040ee82e201e93..310747a3dee2735be6b40871c024129110876ef6 100644 (file)
@@ -185,17 +185,42 @@ class cmd_domainlevel(Command):
 
                 # Deactivate mixed/interim domain support
                 if level_domain_mixed != 0:
+                    # Directly on the base DN
                     m = ldb.Message()
                     m.dn = ldb.Dn(samdb, domain_dn)
                     m["nTMixedDomain"] = ldb.MessageElement("0",
                       ldb.FLAG_MOD_REPLACE, "nTMixedDomain")
                     samdb.modify(m)
+                    # Under partitions
+                    m = ldb.Message()
+                    m.dn = ldb.Dn(samdb, "CN=" + lp.get("workgroup")
+                      + ",CN=Partitions,CN=Configuration," + domain_dn)
+                    m["nTMixedDomain"] = ldb.MessageElement("0",
+                      ldb.FLAG_MOD_REPLACE, "nTMixedDomain")
+                    try:
+                        samdb.modify(m)
+                    except LdbError, (num, _):
+                        pass
+
+                # Directly on the base DN
                 m = ldb.Message()
                 m.dn = ldb.Dn(samdb, domain_dn)
                 m["msDS-Behavior-Version"]= ldb.MessageElement(
                   str(new_level_domain), ldb.FLAG_MOD_REPLACE,
                           "msDS-Behavior-Version")
                 samdb.modify(m)
+                # Under partitions
+                m = ldb.Message()
+                m.dn = ldb.Dn(samdb, "CN=" + lp.get("workgroup")
+                  + ",CN=Partitions,CN=Configuration," + domain_dn)
+                m["msDS-Behavior-Version"]= ldb.MessageElement(
+                  str(new_level_domain), ldb.FLAG_MOD_REPLACE,
+                          "msDS-Behavior-Version")
+                try:
+                    samdb.modify(m)
+                except LdbError, (num, _):
+                    pass
+
                 level_domain = new_level_domain
                 msgs.append("Domain function level changed!")