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