From ec9fa906c79c4f71d0230dd57dfde6dd67f37201 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sat, 3 Jul 2010 11:07:10 +0200 Subject: s4:dsdb/tests/passwords.py - set and reset the "minPwdAge" properly After a patch proposal of Nadya and some reflection I think that it's really worth to change all tests which need a "0" "minPwdAge" to set it manually and reset the default afterwards. So we can finally introduce the default "minPwdAge" on provision. Patch proposal by: Nadya Ivanova --- source4/dsdb/tests/python/passwords.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py index bf9e90976a..c288ed524e 100755 --- a/source4/dsdb/tests/python/passwords.py +++ b/source4/dsdb/tests/python/passwords.py @@ -7,8 +7,6 @@ # Notice: This tests will also work against Windows Server if the connection is # secured enough (SASL with a minimum of 128 Bit encryption) - consider # MS-ADTS 3.1.1.3.1.5 -# -# Important: Make sure that the minimum password age is set to "0"! import optparse import sys @@ -584,6 +582,11 @@ res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"]) configuration_dn = res[0]["configurationNamingContext"][0] +# Gets back the basedn +res = ldb.search(base="", expression="", scope=SCOPE_BASE, + attrs=["defaultNamingContext"]) +base_dn = res[0]["defaultNamingContext"][0] + # Get the old "dSHeuristics" if it was set res = ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, " + configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"]) @@ -600,6 +603,16 @@ m["dSHeuristics"] = MessageElement("000000001", FLAG_MOD_REPLACE, "dSHeuristics") ldb.modify(m) +# Get the old "minPwdAge" +res = ldb.search(base_dn, scope=SCOPE_BASE, attrs=["minPwdAge"]) +minPwdAge = res[0]["minPwdAge"][0] + +# Set it temporarely to "0" +m = Message() +m.dn = Dn(ldb, base_dn) +m["minPwdAge"] = MessageElement("0", FLAG_MOD_REPLACE, "minPwdAge") +ldb.modify(m) + runner = SubunitTestRunner() rc = 0 if not runner.run(unittest.makeSuite(PasswordTests)).wasSuccessful(): @@ -616,4 +629,10 @@ else: m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics") ldb.modify(m) +# Reset the "minPwdAge" as it was before +m = Message() +m.dn = Dn(ldb, base_dn) +m["minPwdAge"] = MessageElement(minPwdAge, FLAG_MOD_REPLACE, "minPwdAge") +ldb.modify(m) + sys.exit(rc) -- cgit