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",
# 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":
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")
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),
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),
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
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
message("\n".join(msgs))
else:
- print "ERROR: Wrong argument '" + args[0] + "'!"
+ print >>sys.stderr, "ERROR: Wrong argument '" + args[0] + "'!"
sys.exit(1)