summaryrefslogtreecommitdiff
path: root/swat
diff options
context:
space:
mode:
Diffstat (limited to 'swat')
-rw-r--r--swat/esptest/ldb.esp44
-rw-r--r--swat/scripting/common.js31
-rw-r--r--swat/style/main.css16
3 files changed, 52 insertions, 39 deletions
diff --git a/swat/esptest/ldb.esp b/swat/esptest/ldb.esp
index 1bc75bce73..385a8918c6 100644
--- a/swat/esptest/ldb.esp
+++ b/swat/esptest/ldb.esp
@@ -2,60 +2,26 @@
<h1>Samba4 ldb test</h1>
-<form name="LdbTest" method="post" action="@@request['SCRIPT_NAME']">
- <input name="submit" type="submit" value="Cancel" /><br />
-</form>
-
-<%
-if (request['REQUEST_METHOD'] == "POST") {
- /* if they cancelled then take them back to the list of tests */
- if (form['submit'] == "Cancel") {
- redirect("/");
- }
-}
-
-/*
- hmm, this gets fairly involved ...
-*/
-function showLdbRes(res) {
- for (i in res) {
- var r = res[i];
- for (j in r) {
- var a = r[j];
- if (typeof(a) == "object") {
- for (k in a) {
- write(j + "[" + k + "]=" + a[k] + "<br />\n");
- }
- } else {
- write(j + "=" + r[j] + "<br />\n");
- }
- }
- write("<p>");
- }
-}
-
-%>
-
-Trying a attribute constrained search on samdb:<p>
+<h3>An attribute constrained search</h3>
<%
var dbfile = lpGet("sam database");
var attrs = new Array("name", "dnsDomain", "objectSid", "dn");
res = ldbSearch(dbfile, "(objectClass=domain)", attrs);
-showLdbRes(res);
+multi_table(res, "dn");
%>
-and now an unconstrained search:<p>
+<h3>An unconstrained search</h3>
<%
var dbfile = lpGet("sam database");
res = ldbSearch(dbfile, "(objectClass=user)");
-showLdbRes(res);
+multi_table(res, "dn");
%>
-and a bad search<br>
+<h3>A search with bad arguments</h3>
<%
res = ldbSearch("foo");
diff --git a/swat/scripting/common.js b/swat/scripting/common.js
index 34f5a958da..cc3ca55468 100644
--- a/swat/scripting/common.js
+++ b/swat/scripting/common.js
@@ -61,3 +61,34 @@ function simple_menu() {
}
write("</ul>\n");
}
+
+
+/*
+ display a ejs object as a table
+*/
+function simple_table(v) {
+ write("<table class=\"data\">\n");
+ for (r in v) {
+ write("<tr><td>" + r + "</td><td>" + v[r] + "</td></tr>\n");
+ }
+ write("</table>\n");
+}
+
+/*
+ display an array of objects, with the header for each element from the given
+ attribute
+*/
+function multi_table(array, header) {
+ write("<table class=\"data\">\n");
+ for (i in array) {
+ var v = array[i];
+ write("<tr><th colspan=2>" + v[header] + "</th></tr>\n");
+ for (r in v) {
+ if (r != header) {
+ write("<tr><td align=left>" + r +
+ "</td><td align=left>" + v[r] + "</td></tr>\n");
+ }
+ }
+ }
+ write("</table>\n");
+}
diff --git a/swat/style/main.css b/swat/style/main.css
index 15f768d186..791a89d9e0 100644
--- a/swat/style/main.css
+++ b/swat/style/main.css
@@ -105,3 +105,19 @@
text-align:center;
margin:10px 0 25px 0;
}
+
+/*
+ styles for data tables
+*/
+table.data {
+ border: 2px;
+}
+table.data th {
+ margin-top:20px;
+ text-align:left;
+ background-color: #F5C915;
+}
+table.data tr {
+ background-color: #E5C995;
+ text-align:left;
+}