diff options
author | Gémes Géza <geza@kzsdabas.hu> | 2011-11-02 15:33:35 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2011-11-07 17:27:34 +0100 |
commit | 1d9ff23f8ea22d0a9b5efc4ed2565bfc0dc6d92e (patch) | |
tree | 9b626f2e02b260536a4624040bd31a48a2c8c1db | |
parent | b9e6c48678624ba5335d00906c558ea9e0086699 (diff) | |
download | samba-1d9ff23f8ea22d0a9b5efc4ed2565bfc0dc6d92e.tar.gz samba-1d9ff23f8ea22d0a9b5efc4ed2565bfc0dc6d92e.tar.bz2 samba-1d9ff23f8ea22d0a9b5efc4ed2565bfc0dc6d92e.zip |
Add a --random-password option to user create command.
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>
Signed-off-by: Matthias Dieter Wallnöfer <mdw@samba.org>
-rw-r--r-- | source4/scripting/python/samba/netcmd/user.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source4/scripting/python/samba/netcmd/user.py b/source4/scripting/python/samba/netcmd/user.py index cf0a1e7d1c..78e09fd324 100644 --- a/source4/scripting/python/samba/netcmd/user.py +++ b/source4/scripting/python/samba/netcmd/user.py @@ -25,7 +25,7 @@ import sys, ldb from getpass import getpass from samba.auth import system_session from samba.samdb import SamDB -from samba import gensec +from samba import gensec, generate_random_password from samba.net import Net from samba.netcmd import ( @@ -71,6 +71,9 @@ Example3 shows how to create a new user in the OrgUnit organizational unit. Option("--must-change-at-next-login", help="Force password to be changed on next login", action="store_true"), + Option("--random-password", + help="Generate random password", + action="store_true"), Option("--use-username-as-cn", help="Force use of username as user's CN", action="store_true"), @@ -97,12 +100,15 @@ Example3 shows how to create a new user in the OrgUnit organizational unit. takes_args = ["username", "password?"] def run(self, username, password=None, credopts=None, sambaopts=None, - versionopts=None, H=None, must_change_at_next_login=None, + versionopts=None, H=None, must_change_at_next_login=None, random_password=False, use_username_as_cn=None, userou=None, surname=None, given_name=None, initials=None, profile_path=None, script_path=None, home_drive=None, home_directory=None, job_title=None, department=None, company=None, description=None, mail_address=None, internet_address=None, telephone_number=None, physical_delivery_office=None): + if random_password is not False: + password = generate_random_password(128, 255) + while 1: if password is not None and password is not '': break @@ -382,17 +388,23 @@ Example3 shows how an administrator would reset TestUser3 user's password to pas Option("--must-change-at-next-login", help="Force password to be changed on next login", action="store_true"), + Option("--random-password", + help="Generate random password", + action="store_true"), ] takes_args = ["username?"] def run(self, username=None, filter=None, credopts=None, sambaopts=None, versionopts=None, H=None, newpassword=None, - must_change_at_next_login=None): + must_change_at_next_login=None, random_password=False): if filter is None and username is None: raise CommandError("Either the username or '--filter' must be specified!") - password = newpassword + if random_password is not False: + password = generate_random_password(128, 255) + else: + password = newpassword while 1: if password is not None and password is not '': break |