r19971: typo fix
[ira/wip.git] / testprogs / ejs / ejsnet.js
1 #!/usr/bin/env smbscript
2
3 var options = GetOptions(ARGV, 
4                 "POPT_AUTOHELP",
5                 "POPT_COMMON_SAMBA",
6                 "POPT_COMMON_CREDENTIALS");
7 if (options == undefined) {
8    println("Failed to parse options");
9    return -1;
10 }
11
12 if (options.ARGV.length != 2) {
13    println("Usage: ejsnet.js <DOMAIN> <NEW USER NAME>");
14    return -1;
15 }
16
17 /* use command line creds if available */
18 var creds = options.get_credentials();
19
20 var ctx = NetContext(creds);
21 var usr_ctx = ctx.UserMgr(options.ARGV[0]);
22 if (usr_ctx == undefined) {
23         println("Couldn't get user management context.");
24         return -1;
25 }
26
27 var status = usr_ctx.Create(options.ARGV[1]);
28 if (status.is_ok != true) {
29         println("Failed to create user account " + options.ARGV[1] + ": " + status.errstr);
30         return -1;
31 }
32
33 var status = usr_ctx.Delete(options.ARGV[1]);
34 if (status.is_ok != true) {
35         println("Failed to delete user account " + options.ARGV[1] + ": " + status.errstr);
36         return -1;
37 }
38
39 print ("OK\n");
40 return 0;