except ImportError as e:
pass
+
def check_random():
if get_random_bytes_fn is not None:
return None
return "Crypto.Random or M2Crypto.Rand required"
+
def get_random_bytes(num):
random_reason = check_random()
if random_reason is not None:
raise ImportError(random_reason)
return get_random_bytes_fn(num)
+
def get_crypt_value(alg, utf8pw, rounds=0):
algs = {
"5": {"length": 43},
# i.e. options = "rounds=20;other=ignored;" will return 20
# if the rounds option is not found or the value is not a number, 0 is returned
# which indicates that the default number of rounds should be used.
+
+
def get_rounds(options):
if not options:
return 0
return 0
return 0
+
try:
random_reason = check_random()
if random_reason is not None:
if len(disabled_virtual_attributes) != 0:
virtual_attributes_help += "Unsupported virtual attributes: %s" % ", ".join(sorted(disabled_virtual_attributes.keys()))
+
class cmd_user_create(Command):
"""Create a new user.
"""
synopsis = "%prog (<username>|--filter <filter>) [options]"
-
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
raise CommandError("%s: %s" % (command, msg))
self.outf.write("Changed password OK\n")
+
class GetPasswordCommand(Command):
def __init__(self):
del obj["userPrincipalName"]
calculated = {}
+
def get_package(name, min_idx=0):
if name in calculated:
return calculated[name]
# Extract the WDigest hash for the value specified by i.
# Builds an htdigest compatible value
DIGEST = "Digest"
+
def get_wDigest(i, primary_wdigest, account_name, account_upn,
domain, dns_domain):
if i == 1:
except IndexError:
return None
-
# get the value for a virtualCrypt attribute.
# look for an exact match on algorithm and rounds in supplemental creds
# if not found calculate using Primary:CLEARTEXT
return password_attrs
+
class cmd_user_getpassword(GetPasswordCommand):
"""Get the password fields of a user/computer account.
self.outf.write("%s" % ldif)
self.outf.write("Got password OK\n")
+
class cmd_user_syncpasswords(GetPasswordCommand):
"""Sync the password of user accounts.
self.samdb_url = H
self.dirsync_filter = dirsync_filter
self.dirsync_attrs = dirsync_attrs
- self.dirsync_controls = ["dirsync:1:0:0", "extended_dn:1:0"];
+ self.dirsync_controls = ["dirsync:1:0:0", "extended_dn:1:0"]
self.password_attrs = password_attrs
self.decrypt_samba_gpg = decrypt_samba_gpg
self.sync_command = sync_command
if pid == 0:
os.setsid()
pid = os.fork()
- if pid == 0: # Actual daemon
+ if pid == 0: # Actual daemon
pid = os.getpid()
log_msg("Daemonized as pid %d (from %d)\n" % (pid, orig_pid))
load_cache()
import resource # Resource usage information.
maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
if maxfd == resource.RLIM_INFINITY:
- maxfd = 1024 # Rough guess at maximum number of open file descriptors.
+ maxfd = 1024 # Rough guess at maximum number of open file descriptors.
logfd = os.open(logfile, os.O_WRONLY | os.O_APPEND | os.O_CREAT, 0o600)
self.outf.write("Using logfile[%s]\n" % logfile)
for fd in range(0, maxfd):
update_pid(None)
return
+
class cmd_user_edit(Command):
"""Modify User AD object.
self.outf.write("Modified User '%s' successfully\n" % username)
+
class cmd_user_show(Command):
"""Display a user AD object.
user_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
self.outf.write(user_ldif)
+
class cmd_user_move(Command):
"""Move a user to an organizational unit/container.
self.outf.write('Moved user "%s" into "%s"\n' %
(username, full_new_parent_dn))
+
class cmd_user(SuperCommand):
"""User management."""