diff options
Diffstat (limited to 'source4/setup/newuser')
-rwxr-xr-x | source4/setup/newuser | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/source4/setup/newuser b/source4/setup/newuser index f622058a5d..991afa36d8 100755 --- a/source4/setup/newuser +++ b/source4/setup/newuser @@ -6,12 +6,16 @@ # Released under the GNU GPL version 3 or later # +import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba.getopt as options import optparse import pwd -import sys from getpass import getpass -from auth import system_session +from samba.auth import system_session from samba.samdb import SamDB parser = optparse.OptionParser("newuser [options] <username> [<password>]") @@ -45,15 +49,9 @@ else: if opts.unixname is None: opts.unixname = username -try: - pwd.getpwnam(opts.unixname) -except KeyError: - print "ERROR: Unix user '%s' does not exist" % opts.unixname - sys.exit(1) - -creds = credopts.get_credentials() - lp = sambaopts.get_loadparm() +creds = credopts.get_credentials(lp) + samdb = SamDB(url=lp.get("sam database"), session_info=system_session(), credentials=creds, lp=lp) samdb.newuser(username, opts.unixname, password) |