mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
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
This commit is contained in:
parent
86cde0a7dc
commit
ec9fa906c7
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user