summaryrefslogtreecommitdiff
path: root/source4/setup/pwsettings
diff options
context:
space:
mode:
Diffstat (limited to 'source4/setup/pwsettings')
-rwxr-xr-xsource4/setup/pwsettings23
1 files changed, 10 insertions, 13 deletions
diff --git a/source4/setup/pwsettings b/source4/setup/pwsettings
index 0bb39d9757..59ed5d29bf 100755
--- a/source4/setup/pwsettings
+++ b/source4/setup/pwsettings
@@ -41,8 +41,8 @@ credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
parser.add_option("-H", help="LDB URL for database or target server", type=str)
parser.add_option("--quiet", help="Be quiet", action="store_true")
-parser.add_option("--complexity",
- help="The password complexity (on | off | default). Default is 'on'", type=str)
+parser.add_option("--complexity", type="choice", choices=["on","off","default"],
+ help="The password complexity (on | off | default). Default is 'on'")
parser.add_option("--history-length",
help="The password history length (<integer> | default). Default is 24.", type=str)
parser.add_option("--min-pwd-length",
@@ -87,10 +87,10 @@ try:
# ticks -> days
min_pwd_age = int(abs(int(res[0]["minPwdAge"][0])) / (1e7 * 60 * 60 * 24))
max_pwd_age = int(abs(int(res[0]["maxPwdAge"][0])) / (1e7 * 60 * 60 * 24))
-except:
- print "ERROR: Could not retrieve password properties!"
+except KeyError:
+ print >>sys.stderr, "ERROR: Could not retrieve password properties!"
if args[0] == "show":
- print "So no settings can be displayed!"
+ print >>sys.stderr, "So no settings can be displayed!"
sys.exit(1)
if args[0] == "show":
@@ -118,9 +118,6 @@ elif args[0] == "set":
elif opts.complexity == "off":
pwd_props = pwd_props & (~DOMAIN_PASSWORD_COMPLEX)
msgs.append("Password complexity deactivated!")
- else:
- print "ERROR: Wrong argument '" + opts.complexity + "'!"
- sys.exit(1)
m["pwdProperties"] = ldb.MessageElement(str(pwd_props),
ldb.FLAG_MOD_REPLACE, "pwdProperties")
@@ -132,7 +129,7 @@ elif args[0] == "set":
pwd_hist_len = int(opts.history_length)
if pwd_hist_len < 0 or pwd_hist_len > 24:
- print "ERROR: Password history length must be in the range of 0 to 24!"
+ print >>sys.stderr, "ERROR: Password history length must be in the range of 0 to 24!"
sys.exit(1)
m["pwdHistoryLength"] = ldb.MessageElement(str(pwd_hist_len),
@@ -146,7 +143,7 @@ elif args[0] == "set":
min_pwd_len = int(opts.min_pwd_length)
if min_pwd_len < 0 or min_pwd_len > 14:
- print "ERROR: Minimum password length must be in the range of 0 to 14!"
+ print >>sys.stderr, "ERROR: Minimum password length must be in the range of 0 to 14!"
sys.exit(1)
m["minPwdLength"] = ldb.MessageElement(str(min_pwd_len),
@@ -160,7 +157,7 @@ elif args[0] == "set":
min_pwd_age = int(opts.min_pwd_age)
if min_pwd_age < 0 or min_pwd_age > 998:
- print "ERROR: Minimum password age must be in the range of 0 to 998!"
+ print >>sys.stderr, "ERROR: Minimum password age must be in the range of 0 to 998!"
sys.exit(1)
# days -> ticks
@@ -177,7 +174,7 @@ elif args[0] == "set":
max_pwd_age = int(opts.max_pwd_age)
if max_pwd_age < 0 or max_pwd_age > 999:
- print "ERROR: Maximum password age must be in the range of 0 to 999!"
+ print >>sys.stderr, "ERROR: Maximum password age must be in the range of 0 to 999!"
sys.exit(1)
# days -> ticks
@@ -197,5 +194,5 @@ elif args[0] == "set":
message("\n".join(msgs))
else:
- print "ERROR: Wrong argument '" + args[0] + "'!"
+ print >>sys.stderr, "ERROR: Wrong argument '" + args[0] + "'!"
sys.exit(1)