summaryrefslogtreecommitdiff
path: root/testprogs/ejs/winreg.js
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-06 00:36:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:24 -0500
commitbc43808d8b1542a40faad5ad66174e61c7589b8f (patch)
treee1872987fab16b9019aa2d87e7f743039e510137 /testprogs/ejs/winreg.js
parent8dde143765822b5d5806a3ea80c468bca0a2178d (diff)
downloadsamba-bc43808d8b1542a40faad5ad66174e61c7589b8f.tar.gz
samba-bc43808d8b1542a40faad5ad66174e61c7589b8f.tar.bz2
samba-bc43808d8b1542a40faad5ad66174e61c7589b8f.zip
r9153: added a sample program for enumerating winreg via js
(This used to be commit 10043db676f9db8d1933b6a5f9ae050cefc538ac)
Diffstat (limited to 'testprogs/ejs/winreg.js')
-rwxr-xr-xtestprogs/ejs/winreg.js97
1 files changed, 97 insertions, 0 deletions
diff --git a/testprogs/ejs/winreg.js b/testprogs/ejs/winreg.js
new file mode 100755
index 0000000000..4d8b97d1c2
--- /dev/null
+++ b/testprogs/ejs/winreg.js
@@ -0,0 +1,97 @@
+#!/usr/bin/env smbscript
+/*
+ test winreg 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");
+
+if (options.ARGV.length != 1) {
+ println("Usage: winreg.js <BINDING>");
+ return -1;
+}
+var binding = options.ARGV[0];
+reg = winreg_init();
+security_init(reg);
+
+print("Connecting to " + binding + "\n");
+status = reg.connect(binding);
+if (status.is_ok != true) {
+ print("Failed to connect to " + binding + " - " + status.errstr + "\n");
+ return -1;
+}
+
+
+
+function list(handle, path, name) {
+ var io = irpcObj();
+ var wtime = new Object();
+ wtime.low = 2147483647;
+ wtime.high = 2147483647;
+ var keyname = new Object();
+ keyname.unknown = 522;
+ keyname.key_name = NULL;
+
+ var idx = 0;
+ for (idx=0;idx >= 0;idx++) {
+ io.input.handle = handle;
+ io.input.enum_index = idx;
+ io.input.key_name_len = 0;
+ io.input.unknown = 1044;
+ io.input.in_name = keyname;
+ io.input.class = "";
+ io.input.last_changed_time = wtime;
+ var status = reg.winreg_EnumKey(io);
+ if (!status.is_ok) return;
+ var out = io.output;
+ if (out.result != "WERR_OK") {
+ return;
+ }
+ printf("%s\\%s\n", path, out.out_name.name);
+
+ io = irpcObj();
+ io.input.handle = handle;
+ io.input.keyname = out.out_name.name;
+ io.input.unknown = 0;
+ io.input.access_mask = reg.SEC_FLAG_MAXIMUM_ALLOWED;
+ status = reg.winreg_OpenKey(io);
+ if (!status.is_ok) return;
+ assert(io.output.result == "WERR_OK");
+
+ list(io.output.handle,
+ path + "\\" + out.out_name.name,
+ out.out_name.name);
+ }
+}
+
+function list_tree(name) {
+ var io = irpcObj();
+ io.input.system_name = NULL;
+ io.input.access_required = reg.SEC_FLAG_MAXIMUM_ALLOWED;
+ status = reg.winreg_OpenHKLM(io);
+ assert(status.is_ok);
+
+ var handle = io.output.handle;
+
+ list(handle, "", NULL);
+}
+
+var trees = new Array("HKCR", "HKLM", "HKPD", "HKU");
+
+for (i=0;i<trees.length;i++) {
+ printf("Listing tree '%s'\n", trees[i]);
+ list_tree(trees[i]);
+}
+
+print("All OK\n");
+return 0;