diff options
author | Amitay Isaacs <amitay@gmail.com> | 2011-11-17 09:34:57 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2011-11-18 14:38:27 +1100 |
commit | 6a2a2dfa5f510fcab964588c29c2991859bbc83f (patch) | |
tree | a4de9395b7cd6c9d82261520fb202e9f8ee3652a /source4/scripting | |
parent | c48a2aa43854636763cd6472ceba7f0c70185689 (diff) | |
download | samba-6a2a2dfa5f510fcab964588c29c2991859bbc83f.tar.gz samba-6a2a2dfa5f510fcab964588c29c2991859bbc83f.tar.bz2 samba-6a2a2dfa5f510fcab964588c29c2991859bbc83f.zip |
samba-tool: Fix the domain account policy max_pwd_age calculation
Windows sets maxPwdAge to -0x8000000000000000 when maximum password
age is set to 0 days.
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/netcmd/domain.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py index f1ebf7e2ba..9f77820855 100644 --- a/source4/scripting/python/samba/netcmd/domain.py +++ b/source4/scripting/python/samba/netcmd/domain.py @@ -386,7 +386,10 @@ class cmd_domain_passwordsettings(Command): cur_min_pwd_len = int(res[0]["minPwdLength"][0]) # ticks -> days cur_min_pwd_age = int(abs(int(res[0]["minPwdAge"][0])) / (1e7 * 60 * 60 * 24)) - cur_max_pwd_age = int(abs(int(res[0]["maxPwdAge"][0])) / (1e7 * 60 * 60 * 24)) + if int(res[0]["maxPwdAge"][0]) == -0x8000000000000000: + cur_max_pwd_age = 0 + else: + cur_max_pwd_age = int(abs(int(res[0]["maxPwdAge"][0])) / (1e7 * 60 * 60 * 24)) except Exception, e: raise CommandError("Could not retrieve password properties!", e) @@ -482,7 +485,10 @@ class cmd_domain_passwordsettings(Command): raise CommandError("Maximum password age must be in the range of 0 to 999!") # days -> ticks - max_pwd_age_ticks = -int(max_pwd_age * (24 * 60 * 60 * 1e7)) + if max_pwd_age == 0: + max_pwd_age_ticks = -0x8000000000000000 + else: + max_pwd_age_ticks = -int(max_pwd_age * (24 * 60 * 60 * 1e7)) m["maxPwdAge"] = ldb.MessageElement(str(max_pwd_age_ticks), ldb.FLAG_MOD_REPLACE, "maxPwdAge") |