Revert "remove unused credentials ejs module."
[kai/samba-autobuild/.git] / testprogs / ejs / ejsnet / nethost.js
1 function PrintNetHostHelp()
2 {
3         println("Host management - available commands:");
4         println("\t domainlist - list users in specified domain");
5 }
6
7
8 function ListDomains(hostCtx)
9 {
10         var domain;
11
12         var list = hostCtx.DomainList();
13         if (list == undefined) {
14                 println("Error when listing domains");
15                 return -1;
16         }
17
18         for (var i = 0; i < list.Count; i++) {
19                 domain = list.Domains[i];
20                 printf("%s\n", domain.Name);
21         }
22
23         printf("\nResult: %s\n", list.Status.errstr);
24 }
25
26
27 function HostManager(ctx, options)
28 {
29         var hostCtx;
30
31         if (options.ARGV.length < 2) {
32                 PrintNetHostHelp();
33                 return -1;
34         }
35
36         var hostCmd = options.ARGV[1];
37
38         if (hostCmd == "domainlist") {
39                 hostCtx = ctx.HostMgr();
40                 ListDomains(hostCtx);
41
42         } else {
43                 println("unknown command");
44         }
45 }