r7088: start on some real structure for the SWAT web pages
[jra/samba/.git] / swat / esptest / ldb.esp
1 <% page_header("columns", "ESP ldb test"); %>
2
3 <h1>Samba4 ldb test</h1>
4
5 <form name="LdbTest" method="post" action="@@request['SCRIPT_NAME']"> 
6     <input name="submit" type="submit" value="Cancel" /><br />
7 </form>
8
9 <%
10 if (request['REQUEST_METHOD'] == "POST") {
11         /* if they cancelled then take them back to the list of tests */
12         if (form['submit'] == "Cancel") {
13                 redirect("/");
14         }
15 }
16
17 /*
18   hmm, this gets fairly involved ...
19 */
20 function showLdbRes(res) {
21         for (i in res) {
22                 var r = res[i];
23                 for (j in r) {
24                         var a = r[j];
25                         if (typeof(a) == "object") {
26                                 for (k in a) {
27                                         write(j + "[" + k + "]=" + a[k] + "<br />\n");
28                                 }
29                         } else {
30                                 write(j + "=" + r[j] + "<br />\n");
31                         }
32                 }
33                 write("<p>");
34         }
35 }
36
37 %>
38
39 Trying a attribute constrained search on samdb:<p>
40
41 <%
42 var dbfile = lpGet("sam database");
43 var attrs = new Array("name", "dnsDomain", "objectSid", "dn");
44
45 res = ldbSearch(dbfile, "(objectClass=domain)", attrs);
46 showLdbRes(res);
47 %>
48
49 and now an unconstrained search:<p>
50
51 <%
52 var dbfile = lpGet("sam database");
53
54 res = ldbSearch(dbfile, "(objectClass=user)");
55 showLdbRes(res);
56 %>
57
58 and a bad search<br>
59
60 <%
61 res = ldbSearch("foo");
62 %>
63
64 all done
65
66 <% page_footer() %>