X-Git-Url: http://git.samba.org/samba.git/?p=ira%2Fwip.git;a=blobdiff_plain;f=testprogs%2Fejs%2Fejsnet.js;h=a5570de34c902581d7e6e9eaa649ed0b52dabd3a;hp=b39d888c3950f69bcc4340c9ed90f8036d14ba6d;hb=43f9d9ba71f51007e80b340600a55fb07d89fd4c;hpb=01d54d13dc66ef2127ac52c64ede53d0790738ec diff --git a/testprogs/ejs/ejsnet.js b/testprogs/ejs/ejsnet.js index b39d888c395..a5570de34c9 100755 --- a/testprogs/ejs/ejsnet.js +++ b/testprogs/ejs/ejsnet.js @@ -1,52 +1,46 @@ #!/usr/bin/env smbscript +libinclude("base.js"); + +/* note: these require specifying a proper path in "js include" parameter */ +libinclude("ejsnet/netusr.js"); +libinclude("ejsnet/nethost.js"); + +function PrintNetHelp() +{ + println("Usage: ejsnet.js [options]"); +} + +/* here we start */ + var options = GetOptions(ARGV, "POPT_AUTOHELP", "POPT_COMMON_SAMBA", "POPT_COMMON_CREDENTIALS"); if (options == undefined) { - println("Failed to parse options"); - return -1; + PrintNetHelp(); + return -1; } -if (options.ARGV.length != 2) { - println("Usage: ejsnet.js "); - return -1; +if (options.ARGV.length < 1) { + PrintNetHelp(); + return -1; } /* use command line creds if available */ var creds = options.get_credentials(); - var ctx = NetContext(creds); -var usr_ctx = ctx.UserMgr(options.ARGV[0]); -if (usr_ctx == undefined) { - println("Couldn't get user management context."); - return -1; -} -var status = usr_ctx.Create(options.ARGV[1]); -if (status.is_ok != true) { - println("Failed to create user account " + options.ARGV[1] + ": " + status.errstr); - return -1; -} +var cmd = options.ARGV[0]; +if (cmd == "user") { + UserManager(ctx, options); +} else if (cmd == "host") { + HostManager(ctx, options); -var info = usr_ctx.Info(options.ARGV[1]); -if (info != null) { - println("UserInfo.AccountName = " + info.AccountName); - println("UserInfo.Description = " + info.Description); - println("UserInfo.FullName = " + info.FullName); - println("UserInfo.AcctExpiry = " + info.AcctExpiry); } else { - println("Null UserInfo returned - account unknown"); -} - - -var status = usr_ctx.Delete(options.ARGV[1]); -if (status.is_ok != true) { - println("Failed to delete user account " + options.ARGV[1] + ": " + status.errstr); + PrintNetHelp(); return -1; } -print ("OK\n"); return 0;