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
,
12 "POPT_COMMON_VERSION",
13 "POPT_COMMON_CREDENTIALS",
19 if (options
== undefined
) {
20 println
("Failed to parse options");
24 libinclude
("base.js");
25 libinclude
("provision.js");
29 print a message
if quiet is not
set
33 if (options
["quiet"] == undefined
) {
34 print
(vsprintf
(arguments
));
47 --username USERNAME choose new username
48 --unixname USERNAME choose unix name of new user
49 --password PASSWORD set password
51 You must provide at least a username
56 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
);