1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#!/usr/bin/env smbscript
/*
test samr calls from ejs
*/
var options = new Object();
ok = GetOptions(ARGV, options,
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"POPT_COMMON_CREDENTIALS");
if (ok == false) {
println("Failed to parse options: " + options.ERROR);
return -1;
}
libinclude("base.js");
libinclude("samr.js");
/*
test the samr_Connect interface
*/
function test_Connect(conn)
{
print("Testing samr_Connect\n");
return samrConnect(conn);
}
/*
test the samr_LookupDomain interface
*/
function test_LookupDomain(conn, handle, domain)
{
print("Testing samr_LookupDomain\n");
return samrLookupDomain(conn, handle, domain);
}
/*
test the samr_OpenDomain interface
*/
function test_OpenDomain(conn, handle, sid)
{
print("Testing samr_OpenDomain\n");
return samrOpenDomain(conn, handle, sid);
}
/*
test the samr_EnumDomainUsers interface
*/
function test_EnumDomainUsers(conn, dom_handle)
{
var i, users;
print("Testing samr_EnumDomainUsers\n");
users = samrEnumDomainUsers(conn, dom_handle);
print("Found " + users.length + " users\n");
for (i=0;i<users.length;i++) {
println("\t" + users[i].name + "\t(" + users[i].idx + ")");
}
}
/*
test the samr_EnumDomainGroups interface
*/
function test_EnumDomainGroups(conn, dom_handle)
{
print("Testing samr_EnumDomainGroups\n");
var i, groups = samrEnumDomainGroups(conn, dom_handle);
print("Found " + groups.length + " groups\n");
for (i=0;i<groups.length;i++) {
println("\t" + groups[i].name + "\t(" + groups[i].idx + ")");
}
}
/*
test domain specific ops
*/
function test_domain_ops(conn, dom_handle)
{
test_EnumDomainUsers(conn, dom_handle);
test_EnumDomainGroups(conn, dom_handle);
}
/*
test the samr_EnumDomains interface
*/
function test_EnumDomains(conn, handle)
{
var i, domains;
print("Testing samr_EnumDomains\n");
domains = samrEnumDomains(conn, handle);
print("Found " + domains.length + " domains\n");
for (i=0;i<domains.length;i++) {
print("\t" + domains[i].name + "\n");
}
for (i=0;i<domains.length;i++) {
print("Testing domain " + domains[i].name + "\n");
sid = samrLookupDomain(conn, handle, domains[i].name);
dom_handle = test_OpenDomain(conn, handle, sid);
test_domain_ops(conn, dom_handle);
samrClose(conn, dom_handle);
}
}
if (options.ARGV.length != 1) {
println("Usage: samr.js <BINDING>");
return -1;
}
var binding = options.ARGV[0];
var conn = new Object();
print("Connecting to " + binding + "\n");
status = rpc_connect(conn, binding, "samr");
if (status.is_ok != true) {
print("Failed to connect to " + binding + " - " + status.errstr + "\n");
return -1;
}
handle = test_Connect(conn);
test_EnumDomains(conn, handle);
samrClose(conn, handle);
print("All OK\n");
return 0;
|