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