summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-07-03 11:07:10 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-07-03 11:28:21 +0200
commitec9fa906c79c4f71d0230dd57dfde6dd67f37201 (patch)
treeedd147f09b049aa686d33a2b33abd91fcdb8fb4d /source4
parent86cde0a7dc8388747060a11f101f715645ef0eae (diff)
downloadsamba-ec9fa906c79c4f71d0230dd57dfde6dd67f37201.tar.gz
samba-ec9fa906c79c4f71d0230dd57dfde6dd67f37201.tar.bz2
samba-ec9fa906c79c4f71d0230dd57dfde6dd67f37201.zip
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
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/dsdb/tests/python/passwords.py23
1 files changed, 21 insertions, 2 deletions
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)