s4:pwsettings script - Fix a small glitch
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Mon, 10 Aug 2009 09:06:33 +0000 (11:06 +0200)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Tue, 11 Aug 2009 10:59:15 +0000 (12:59 +0200)
This fixes the problem with the setting and getting of the "minPwdAge" and
"maxPwdAge" attributes. I wanted to handle them in days but forgot to add
conversions (from "ticks" (tenth of microsecond) -> "days" and backwards).

source4/setup/pwsettings

index 8a4489b2875260a2334da3b36e81b3b00c80df94..a2708531a15601ab82633b26d6bd0bf75c6be4a5 100755 (executable)
@@ -77,8 +77,9 @@ try:
        pwd_props = int(res[0]["pwdProperties"][0])
        pwd_hist_len = int(res[0]["pwdHistoryLength"][0])
        min_pwd_len = int(res[0]["minPwdLength"][0])
-       min_pwd_age = int(res[0]["minPwdAge"][0])
-       max_pwd_age = int(res[0]["maxPwdAge"][0])
+       # ticks -> days
+       min_pwd_age = int(abs(int(res[0]["minPwdAge"][0])) / (10e7 * 60 * 60 * 24))
+       max_pwd_age = int(abs(int(res[0]["maxPwdAge"][0])) / (10e7 * 60 * 60 * 24))
 except:
        if args[0] == "show":
                print "ERROR: Password informations missing in your AD domain object!"
@@ -98,8 +99,8 @@ if args[0] == "show":
                print "Password complexity: off"
        print "Password history length: " + str(pwd_hist_len)
        print "Minimum password length: " + str(min_pwd_len)
-       print "Minimum password age: " + str(min_pwd_age)
-       print "Maximum password age: " + str(max_pwd_age)
+       print "Minimum password age (days): " + str(min_pwd_age)
+       print "Maximum password age (days): " + str(max_pwd_age)
 
 elif args[0] == "set":
        if opts.complexity is not None:
@@ -168,6 +169,8 @@ elif args[0] == "set":
                        min_pwd_age = 0
                else:
                        min_pwd_age = int(opts.min_pwd_age)
+               # days -> ticks
+               min_pwd_age = -int(min_pwd_age * (24 * 60 * 60 * 10e7))
 
                m = ldb.Message()
                m.dn = ldb.Dn(samdb, domain_dn)
@@ -181,9 +184,11 @@ elif args[0] == "set":
 
        if opts.max_pwd_age is not None:
                if opts.max_pwd_age == "default":
-                       max_pwd_age = -37108517437440
+                       max_pwd_age = 43
                else:
                        max_pwd_age = int(opts.max_pwd_age)
+               # days -> ticks
+               max_pwd_age = -int(max_pwd_age * (24 * 60 * 60 * 10e7))
 
                m = ldb.Message()
                m.dn = ldb.Dn(samdb, domain_dn)