1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
samba-mirror/testprogs/ejs/ejsnet.js
Andrew Bartlett a5e7c17c34 r12892: Add a 'Migrate from Windows' page to our installation section in SWAT.
Doing this required reworking ejsnet, particularly so it could take a
set of credentials, not just a username and password argument.

This required fixing the ejsnet.js test script, which now adds and
deletes a user, and is run from 'make test'.  This should prevent it
being broken again.

Deleting a user from ejsnet required that the matching backend be
added to libnet, hooking fortunetly onto already existing code for the
actual deletion.

The js credentials interface now handles the 'set machine account' flag.

New functions have been added to provision.js to wrap the basic
operations (so we can write a command line version, as well as the web
based version).

Andrew Bartlett
2007-10-10 13:50:59 -05:00

41 lines
942 B
JavaScript
Executable File

#!/usr/bin/env smbscript
var options = GetOptions(ARGV,
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"POPT_COMMON_CREDENTIALS");
if (options == undefined) {
println("Failed to parse options");
return -1;
}
if (options.ARGV.length != 2) {
println("Usage: ejsnet.js <DOMAIN> <NEW USER NAME>");
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("Couln'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 status = usr_ctx.Delete(options.ARGV[1]);
if (status.is_ok != true) {
println("Failed to delete user account " + options.ARGV[1] + ": " + status.errstr);
return -1;
}
print ("OK\n");
return 0;