Handle hostnames with upper-case letters
[webmin.git] / ldap-server / edit_slapd.cgi
1 #!/usr/local/bin/perl
2 # Show local LDAP server configuration options
3
4 require './ldap-server-lib.pl';
5 &local_ldap_server() == 1 || &error($text{'slapd_elocal'});
6 $access{'slapd'} || &error($text{'slapd_ecannot'});
7 &ui_print_header(undef, $text{'slapd_title'}, "", "slapd");
8 $conf = &get_config();
9 @tds = ( "width=30%" );
10
11 print &ui_form_start("save_slapd.cgi", "post");
12 print &ui_hidden_table_start($text{'slapd_header'}, "width=100%", 2,
13                              "basic", 1,\@tds);
14
15 # Top-level DN
16 $suffix = &find_value('suffix', $conf);
17 print &ui_table_row($text{'slapd_suffix'},
18                     &ui_textbox('suffix', $suffix, 60));
19
20 # Admin login
21 $rootdn = &find_value('rootdn', $conf);
22 print &ui_table_row($text{'slapd_rootdn'},
23                     &ui_textbox('rootdn', $rootdn, 60));
24
25 # Admin password
26 $rootpw = &find_value('rootpw', $conf);
27 if ($rootpw =~ /^{crypt}(.*)/i) {
28         $rootmode = 1;
29         $rootcrypt = $1;
30         }
31 elsif ($rootpw =~ /^{sha1}(.*)/i) {
32         $rootmode = 2;
33         $rootsha1 = $1;
34         }
35 elsif ($rootpw =~ /^{[a-z0-9]+}(.*)/i) {
36         $rootmode = 3;
37         $rootenc = $rootpw;
38         }
39 else {
40         $rootmode = 0;
41         $rootplain = $rootpw;
42         }
43
44 # Current password
45 print &ui_table_row($text{'slapd_rootpw'},
46                     $rootmode == 1 ? &text('slapd_root1', $rootcrypt) :
47                     $rootmode == 2 ? &text('slapd_root2', $rootsha1) :
48                     $rootmode == 3 ? &text('slapd_root3', $rootenc) :
49                     $rootplain eq '' ? $text{'slapd_noroot'} :
50                                      $rootplain);
51
52 # Set to new
53 print &ui_table_row($text{'slapd_rootchange'},
54                     &ui_opt_textbox('rootchange', undef, 30,
55                         $text{'slapd_leave'}, $text{'slapd_set'}));
56
57 # Cache sizes
58 $cachesize = &find_value('cachesize', $conf);
59 print &ui_table_row($text{'slapd_cachesize'},
60             &ui_opt_textbox("cachesize", $cachesize, 10, $text{'default'}));
61 $dbcachesize = &find_value('dbcachesize', $conf);
62 print &ui_table_row($text{'slapd_dbcachesize'},
63             &ui_opt_textbox("dbcachesize", $dbcachesize, 10, $text{'default'}));
64
65 # Access control options
66 $allowdir = &find("allow", $conf);
67 @allow = $allowdir ? @{$allowdir->{'values'}} : ( );
68 print &ui_table_row($text{'slapd_allow'},
69     &ui_select("allow", \@allow,
70                [ map { [ $_, $text{'slapd_'.$_} ] }
71                      ( 'bind_v2', 'bind_anon_cred',
72                        'bind_anon_dn', 'update_anon' ) ], 4, 1, 1));
73
74 # Size and time limits
75 $sizelimit = &find_value('sizelimit', $conf);
76 print &ui_table_row($text{'slapd_sizelimit'},
77     &ui_opt_textbox('sizelimit', $sizelimit, 10, $text{'default'}." (500)"));
78 $timelimit = &find_value('timelimit', $conf);
79 print &ui_table_row($text{'slapd_timelimit'},
80     &ui_opt_textbox('timelimit', $timelimit, 10,
81                     $text{'default'}." (3600 $text{'slapd_secs'})").
82     " ".$text{'slapd_secs'});
83
84 print &ui_hidden_table_end("basic");
85
86 # SSL section
87 print &ui_hidden_table_start($text{'slapd_header2'}, "width=100%", 2,
88                              "ssl", 0, \@tds);
89
90 # Protocols to serve
91 if (&can_get_ldap_protocols()) {
92         $protos = &get_ldap_protocols();
93         @protos = sort { $a cmp $b } keys %$protos;
94         print &ui_table_row($text{'slapd_protos'},
95                 &ui_select("protos",
96                            [ grep { $protos->{$_} } @protos ],
97                            [ map { [ $_, $text{'slapd_'.$_} ] } @protos ],
98                            scalar(@protos), 1));
99         }
100
101 # SSL file options
102 $anycert = 0;
103 foreach $s ([ 'TLSCertificateFile', 'cert' ],
104             [ 'TLSCertificateKeyFile', 'key' ],
105             [ 'TLSCACertificateFile', 'ca' ]) {
106         $cert = &find_value($s->[0], $conf);
107         print &ui_table_row($text{'slapd_'.$s->[1]},
108                 &ui_opt_textbox($s->[1], $cert, 50, $text{'slapd_none'}).
109                 &file_chooser_button($s->[1]));
110         $anycert = 1 if ($cert);
111         }
112
113 print &ui_hidden_table_end("ssl");
114 print &ui_form_end([ [ undef, $text{'save'} ] ]);
115
116 # SSL setup button
117 print &ui_hr();
118 print &ui_buttons_start();
119 print &ui_buttons_row("gencert_form.cgi", $text{'slapd_gencert'},
120                       $text{'slapd_gencertdesc'}.
121                       ($anycert ? "<b>$text{'slapd_gencertwarn'}</b>" : ""));
122 print &ui_buttons_end();
123
124 &ui_print_footer("", $text{'index_return'});
125