2 exec smbscript "$0" ${1+"$@"}
4 add a new user to a Samba4 server
5 Copyright Andrew Tridgell 2005
6 Released under the GNU GPL v2 or later
9 options = GetOptions(ARGV,
15 "POPT_COMMON_VERSION",
16 "POPT_COMMON_CREDENTIALS",
19 if (options == undefined) {
20 println("Failed to parse options");
24 libinclude("base.js");
25 libinclude("provision.js");
28 print a message if quiet is not set
32 if (options["quiet"] == undefined) {
33 print(vsprintf(arguments));
46 --username USERNAME choose new username
47 --unixname USERNAME choose unix name of new user
48 --password PASSWORD set password
50 You must provide at least a username
55 if (options['username'] == undefined) {
59 if (options['password'] == undefined) {
61 options.password = randpass(12);
62 printf("chose random password %s\n", options.password);
64 if (options['unixname'] == undefined) {
65 options.unixname = options.username;
69 if (nss.getpwnam(options.unixname) == undefined) {
70 printf("ERROR: Unix user '%s' does not exist\n", options.unixname);
74 var creds = options.get_credentials();
75 var system_session = system_session();
78 newuser(options.username, options.unixname, options.password, message, system_session, creds);