From 1f38aa0995f7ffa82f670fe5d36046dd6b8f44ac Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 18 Sep 2009 20:22:03 +0200 Subject: s4:various scripts under "setup" - Unification - This unified the shape of those four scripts (comments, command sequence, call of SamDB) - To consider the samdb.py changes regarding the filter: there is now always the possibility either to specify the username or the search filter --- source4/setup/newuser | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/setup/newuser') diff --git a/source4/setup/newuser b/source4/setup/newuser index cc89e922a7..422677c301 100755 --- a/source4/setup/newuser +++ b/source4/setup/newuser @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Add a new user to a Samba4 server +# Adds a new user to a Samba4 server # Copyright Jelmer Vernooij 2008 # # Based on the original in EJS: @@ -18,6 +18,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . + import sys # Find right directory when running from source tree @@ -25,8 +26,10 @@ sys.path.insert(0, "bin/python") import samba.getopt as options import optparse + from getpass import getpass from samba.auth import system_session +from samba.samdb import SamDB parser = optparse.OptionParser("newuser [options] []") sambaopts = options.SambaOptions(parser) @@ -34,7 +37,6 @@ parser.add_option_group(sambaopts) parser.add_option_group(options.VersionOptions(parser)) credopts = options.CredentialsOptions(parser) parser.add_option_group(credopts) -parser.add_option("--quiet", help="Be quiet", action="store_true") parser.add_option("--unixname", help="Unix Username", type=str) parser.add_option("--must-change-at-next-login", help="Force password to be changed on next login", action="store_true") @@ -56,6 +58,6 @@ if opts.unixname is None: lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) -samdb = sambaopts.get_hostconfig().get_samdb(session_info=system_session(), - credentials=creds) +samdb = SamDB(url=lp.get("sam database"), session_info=system_session(), + credentials=creds, lp=lp) samdb.newuser(username, opts.unixname, password, force_password_change_at_next_login=opts.must_change_at_next_login) -- cgit