s4:various scripts under "setup" - Unification
[samba.git] / source4 / setup / newuser
index cc89e922a74e2b4d9f3960281c78a46ed2aa6c8a..422677c301fb137a1f99abda1d5d4ddce020fcca 100755 (executable)
@@ -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 <http://www.gnu.org/licenses/>.
+
 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] <username> [<password>]")
 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)