wintest Remove the password expiry as the first step
authorAndrew Bartlett <abartlet@samba.org>
Thu, 9 Dec 2010 11:05:14 +0000 (22:05 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 9 Dec 2010 12:33:00 +0000 (13:33 +0100)
This is particularly important before dcpromo, as the password will
otherwise be expired in the new domain.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Thu Dec  9 13:33:00 CET 2010 on sn-devel-104

wintest/test-s4-howto.py
wintest/wintest.py

index 2dbb208dbad1cab35c4853c5cbf767563db54509..e97963f8f34c3a835dd516cb95da5fecd4359793 100755 (executable)
@@ -299,7 +299,7 @@ def run_winjoin(t, vm):
     t.info("Joining a windows box to the domain")
     t.vm_poweroff("${WIN_VM}", checkfail=False)
     t.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
-    child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_USER}", "${WIN_PASS}", set_time=True, set_ip=True)
+    child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_USER}", "${WIN_PASS}", set_time=True, set_ip=True, set_noexpire=True)
     child.sendline("netdom join ${WIN_HOSTNAME} /Domain:${LCREALM} /PasswordD:${PASSWORD1} /UserD:administrator")
     child.expect("The command completed successfully")
     child.expect("C:")
@@ -332,7 +332,7 @@ def run_dcpromo(t, vm):
     t.info("Joining a windows VM ${WIN_VM} to the domain as a DC using dcpromo")
     t.vm_poweroff("${WIN_VM}", checkfail=False)
     t.vm_restore("${WIN_VM}", "${WIN_SNAPSHOT}")
-    child = t.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_ip=True)
+    child = t.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_ip=True, set_noexpire=True)
     child.sendline("copy /Y con answers.txt")
     child.sendline('''
 [DCINSTALL]
@@ -736,7 +736,7 @@ def run_dcpromo_as_first_dc(t, vm, func_level=None):
     else:
         t.setvar("FUNCTION_LEVEL_INT", str(0))
 
-    child = t.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_ip=True)
+    child = t.open_telnet("${WIN_HOSTNAME}", "administrator", "${WIN_PASS}", set_ip=True, set_noexpire=True)
 
     """This server must therefore not yet be a directory server, so we must promote it"""
     child.sendline("copy /Y con answers.txt")
index ec2624bde5541ce0bafcf279e1a922a6ac48db44..0d65116562a369629d432ce2a7f6295b59aa4135 100644 (file)
@@ -371,6 +371,12 @@ class wintest():
         if hostname.upper() == self.getvar("WIN_HOSTNAME").upper():
             return True
 
+    def set_noexpire(self, child, username):
+        '''Ensure this user's password does not expire'''
+        child.sendline('wmic useraccount where name="%s" set PasswordExpires=FALSE' % username)
+        child.expect("update successful")
+        child.expect("C:")
+
     def run_tlntadmn(self, child):
         '''remove the annoying telnet restrictions'''
         child.sendline('tlntadmn config maxconn=1024')
@@ -438,7 +444,7 @@ class wintest():
 
 
     def open_telnet(self, hostname, username, password, retries=60, delay=5, set_time=False, set_ip=False,
-                    disable_firewall=True, run_tlntadmn=True):
+                    disable_firewall=True, run_tlntadmn=True, set_noexpire=False):
         '''open a telnet connection to a windows server, return the pexpect child'''
         set_route = False
         set_dns = False
@@ -491,6 +497,9 @@ class wintest():
             if run_tlntadmn:
                 self.run_tlntadmn(child)
                 run_tlntadmn = False
+            if set_noexpire:
+                self.set_noexpire(child, username)
+                set_noexpire = False
             if disable_firewall:
                 self.disable_firewall(child)
                 disable_firewall = False