3 # Edit an existing samba user
5 require './samba-lib.pl';
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'};
13 &ui_print_header(undef, $text{'euser_title'}, "");
14 @ulist = &list_users();
15 $u = $ulist[$in{'idx'}];
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";
23 print "<tr> <td align=right><b>$text{'euser_name'}</b></td>\n";
24 print "<td><tt>$u->{'name'}</tt></td>\n";
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";
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
34 print "<td colspan=3><input type=radio name=ptype value=2 checked> ",
35 "$text{'euser_currpw'}\n";
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";
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";
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";
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";
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",
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]});
76 foreach $oo (keys %opt) {
77 print "<input type=hidden name=opts value=$oo>\n";
79 print "</td> </tr>\n";
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";
90 &ui_print_footer("edit_epass.cgi", $text{'index_userlist'},
91 "", $text{'index_sharelist'});