Handle hostnames with upper-case letters
[webmin.git] / samba / edit_euser.cgi
1 #!/usr/local/bin/perl
2 # edit_euser.cgi
3 # Edit an existing samba user
4
5 require './samba-lib.pl';
6 &ReadParse();
7 # check acls
8
9 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
10 &error("$text{'eacl_np'} $text{'eacl_pvusers'}")
11         unless $access{'view_users'};
12 # display               
13 &ui_print_header(undef, $text{'euser_title'}, "");
14 @ulist = &list_users();
15 $u = $ulist[$in{'idx'}];
16
17 print "<form action=save_euser.cgi>\n";
18 print "<input type=hidden name=idx value=\"$in{'idx'}\">\n";
19 print "<table border width=100%>\n";
20 print "<tr $tb> <td><b>$text{'euser_title'}</b></td> </tr>\n";
21 print "<tr $cb> <td><table width=100%>\n";
22
23 print "<tr> <td align=right><b>$text{'euser_name'}</b></td>\n";
24 print "<td><tt>$u->{'name'}</tt></td>\n";
25
26 print "<td align=right><b>$text{'euser_uid'}</b></td>\n";
27 print "<td><input name=uid size=5 value=\"$u->{'uid'}\"></td> </tr>\n";
28
29 print "<tr> <td align=right><b>$text{'euser_passwd'}</b></td>\n";
30 if ($samba_version >= 3) {
31         # In the new Samba, the password field is not really used for locking
32         # accounts any more, so don't both with the no access/no password
33         # options.
34         print "<td colspan=3><input type=radio name=ptype value=2 checked> ",
35               "$text{'euser_currpw'}\n";
36         }
37 else {
38         # In the old Samba, you can set the password to deny a login to the
39         # account or allow logins without a password
40         $locked = ($u->{'pass1'} eq ("X" x 32));
41         $nopass = ($u->{'pass1'} =~ /^NO PASSWORD/);
42         printf "<td colspan=3><input type=radio name=ptype value=0 %s> $text{'euser_noaccess'}\n",
43                 $locked ? "checked" : "";
44         printf "<input type=radio name=ptype value=1 %s> $text{'euser_nopw'}\n",
45                 $nopass ? "checked" : "";
46         printf "<input type=radio name=ptype value=2 %s> $text{'euser_currpw'}\n",
47                 $locked||$nopass ? "" : "checked";
48         }
49 print "<input type=radio name=ptype value=3> $text{'euser_newpw'}\n";
50 print "<input type=password name=pass size=20></td> </tr>\n";
51
52 if (!$u->{'opts'}) {
53         # Old-style samba user
54         print "<tr> <td align=right><b>$text{'euser_realname'}</b></td> <td colspan=3>\n";
55         print "<input name=realname size=40 value='$u->{'real'}'></td> </tr>\n";
56
57         print "<tr> <td align=right><b>$text{'euser_homedir'}</b></td>\n";
58         print "<td><input name=homedir size=30 value='$u->{'home'}'></td>\n";
59
60         print "<td align=right><b>$text{'euser_shell'}</b></td>\n";
61         printf "<td><input name=shell size=15 value='%s'></td> </tr>\n",
62                 $u->{'shell'};
63         }
64 else {
65         # New-style samba user
66         print "<input type=hidden name=new value=1>\n";
67         map { $opt{uc($_)}++ } @{$u->{'opts'}};
68         print "<tr> <td valign=top align=right><b>$text{'euser_option'}</b></td> <td colspan=3>\n";
69         @ol = ($text{'euser_normal'}, "U", $text{'euser_nopwrequired'}, "N",
70                $text{'euser_disable'}, "D", $text{'euser_locked'}, "L" ,$text{'euser_noexpire'}, "X", $text{'euser_trust'}, "W");
71         for($i=0; $i<@ol; $i+=2) {
72                 printf "<input type=checkbox name=opts value=%s %s> %s<br>\n",
73                         $ol[$i+1], $opt{$ol[$i+1]} ? "checked" : "", $ol[$i];
74                 delete($opt{$ol[$i+1]});
75                 }
76         foreach $oo (keys %opt) {
77                 print "<input type=hidden name=opts value=$oo>\n";
78                 }
79         print "</td> </tr>\n";
80         }
81
82 print "</table></td></tr></table>\n";
83 print "<table width=100%>\n";
84 print "<tr> <td><input type=submit value=$text{'save'}></td>\n";
85 print "</form><form action=\"delete_euser.cgi\">\n";
86 print "<input type=hidden name=idx value=\"$in{'idx'}\">\n";
87 print "<td align=right><input type=submit value=$text{'delete'}></td> </tr>\n";
88 print "</form></table><p>\n";
89
90 &ui_print_footer("edit_epass.cgi", $text{'index_userlist'},
91         "", $text{'index_sharelist'});
92