r7088: start on some real structure for the SWAT web pages
[sfrench/samba-autobuild/.git] / swat / esptest / auth.esp
1 <% page_header("columns", "ESP Authentication Test"); %>
2
3 <h1>Samba4 unixAuth test</h1>
4
5 <form name="AuthTest" method="POST" action="@@request['SCRIPT_NAME']"> 
6     <input name="submit" type="submit" value="Logout">
7     <input name="submit" type="submit" value="Cancel"><br>
8     <br>
9     Username:   <input name="Username"  type="text" value=""><br>
10     Password:  <input name="Password" type="password" value=""><br>
11     <br>
12     <input name="submit" type="submit" value="Login"><br>
13 </form>
14
15 <%
16   /* if its a post then the user has filled in the form, so
17      report the values 
18   */
19 if (request['REQUEST_METHOD'] == "POST") {
20         /* if they cancelled then take them back to the list of tests */
21         if (form['submit'] == "Cancel") {
22                 redirect("/");
23         }
24         
25         username  = form['Username'];
26         password = form['Password'];
27         
28         if (form['submit'] == "Logout") {
29                 res = unixAuth("logout", "logout");
30         }
31         
32         if (form['submit'] == "Login") {
33                 res = unixAuth(username, password);
34                 if (res != 0) {
35                         write ("<br>Unsuccessful authentication\n");
36                 } else {
37                         write ("<br>Successfully authenticated\n");
38                 }
39         }
40 }
41
42 write ("<br>AUTHENTICATED = " + session['AUTHENTICATED'] + "\n");
43 write ("<br>USERNAME = " + session['USERNAME'] + "\n");
44 write ("<br>PRIVILEGE = " + session['PRIVILEGE'] + "\n");
45
46 %>
47
48 <% page_footer(); %>