diff options
Diffstat (limited to 'swat')
-rw-r--r-- | swat/esptest/menu.js | 1 | ||||
-rw-r--r-- | swat/esptest/provision.esp | 55 | ||||
-rw-r--r-- | swat/scripting/common.js | 31 |
3 files changed, 85 insertions, 2 deletions
diff --git a/swat/esptest/menu.js b/swat/esptest/menu.js index d46561f311..d2a145cc5c 100644 --- a/swat/esptest/menu.js +++ b/swat/esptest/menu.js @@ -1,6 +1,7 @@ /* show a menu for the esp test pages */ simple_menu( "ESP Tests", + "Provisioning", session_uri("/esptest/provision.esp"), "ldb database", session_uri("/esptest/ldb.esp"), "samr calls", session_uri("/esptest/samr.esp"), "html forms", session_uri("/esptest/formtest.esp"), diff --git a/swat/esptest/provision.esp b/swat/esptest/provision.esp new file mode 100644 index 0000000000..b2f5fbf618 --- /dev/null +++ b/swat/esptest/provision.esp @@ -0,0 +1,55 @@ +<% page_header("columns", "Server provisioning"); + + libinclude("base.js"); + libinclude("provision.js"); +%> + +<h1>Samba4 provisioning</h1> + +<% +var f = FormObj("Provisioning", 9, 2); +var i, subobj = provision_guess(); + +f.element[0].label = "Realm"; +f.element[0].name = "REALM"; +f.element[1].label = "Domain Name"; +f.element[1].name = "DOMAIN"; +f.element[2].label = "Host Name"; +f.element[2].name = "HOSTNAME"; +f.element[3].label = "Administrator Password"; +f.element[3].name = "ADMINPASS"; +f.element[4].label = "Domain SID"; +f.element[4].name = "DOMAINSID"; +f.element[5].label = "Host GUID"; +f.element[5].name = "HOSTGUID"; +f.element[6].label = "Base DN"; +f.element[6].name = "BASEDN"; +f.element[7].label = "Host IP"; +f.element[7].name = "HOSTIP"; +f.element[8].label = "Default Site"; +f.element[8].name = "DEFAULTSITE"; +f.submit[0] = "Provision"; +f.submit[1] = "Cancel"; + +if (form['submit'] == "Cancel") { + redirect("/"); +} + +if (form['submit'] == "Provision") { + for (r in form) { + subobj[r] = form[r]; + } +} + +for (i=0;i<f.element.length;i++) { + f.element[i].value = subobj[f.element[i].name]; +} +if (form['submit'] == "Provision") { + provision(subobj, writefln); +} else { + display_form(f); +} +%> + + +<% page_footer(); %> diff --git a/swat/scripting/common.js b/swat/scripting/common.js index 2e90c1b469..0e297d7d99 100644 --- a/swat/scripting/common.js +++ b/swat/scripting/common.js @@ -23,6 +23,22 @@ function session_uri(uri) { return uri + global.SESSIONURI; } +/* + like printf, but to the web page +*/ +function writef() +{ + write(vsprintf(arguments)); +} + +/* + like writef with a <br> +*/ +function writefln() +{ + write(vsprintf(arguments)); + write("<br/>\n"); +} /* if the browser was too dumb to set the HOST header, then @@ -196,6 +212,7 @@ function FormObj(name, num_elements, num_submits) f.element[i].value = current value (optional, defaults to "") */ function display_form(f) { + var i, size = 20; write('<form name="' + f.name + '" method="post" action="' + f.action + '" class="' + f.class + '">\n'); @@ -210,6 +227,12 @@ function display_form(f) { if (e.value == undefined) { e.value = ""; } + if (strlen(e.value) > size) { + size = strlen(e.value) + 4; + } + } + for (i in f.element) { + var e = f.element[i]; write("<tr>"); write("<td>" + e.label + "</td>"); if (e.type == "select") { @@ -223,8 +246,12 @@ function display_form(f) { } write('</select></td>\n'); } else { - write('<td><input name="' + e.name + '" type="' + - e.type + '" value="' + e.value + '" /></td>\n'); + var sizestr = ""; + if (e.type == "text" || e.type == "password") { + sizestr = sprintf('size="%d"', size); + } + writef('<td><input name="%s" type="%s" value="%s" %s /></td>\n', + e.name, e.type, e.value, sizestr); } write("</tr>"); } |