2 # Show the details of one access control rule
4 require './ldap-server-lib.pl';
5 &local_ldap_server() == 1 || &error($text{'slapd_elocal'});
6 $access{'acl'} || &error($text{'acl_ecannot'});
10 if (&get_config_type() == 1) {
11 $conf = &get_config();
12 @access = &find("access", $conf);
15 $defdb = &get_default_db();
16 $conf = &get_ldif_config();
17 @access = &find_ldif("olcAccess", $conf, $defdb);
22 &ui_print_header(undef, $text{'eacl_title1'}, "", "eacl");
27 &ui_print_header(undef, $text{'eacl_title2'}, "", "eacl");
28 $acl = $access[$in{'idx'}];
29 $p = &parse_ldap_access($acl);
33 print &ui_form_start("acl_save.cgi", "post");
34 print &ui_hidden("new", $in{'new'});
35 print &ui_hidden("idx", $in{'idx'});
36 print &ui_table_start($text{'eacl_header'}, undef, 2);
38 # Granting to what object
39 $what = $p->{'what'} eq '*' || $p->{'what'} eq '' ? 1 : 0;
40 if ($p->{'what'} =~ /^dn(\.([^=]+))?="(.*)"$/i ||
41 $p->{'what'} =~ /^dn(\.([^=]+))?=(.*)$/i) {
48 print &ui_table_row($text{'eacl_what'},
49 &ui_radio_table("what", $what,
50 [ [ 1, $text{'eacl_what1'} ],
51 [ 2, $text{'eacl_what2'} ],
52 [ 0, $text{'eacl_what0'},
53 &ui_textbox("what_dn", $dn, 30)." ".
54 $text{'eacl_mtype'}." ".
55 &ui_select("what_style", $style,
56 [ [ '', $text{'default'} ],
57 map { [ $_, $text{'eacl_'.$_} ] }
58 @acl_dn_styles ]) ] ])."\n".
59 &ui_checkbox("filter_on", 1, $text{'eacl_filter'}, $p->{'filter'})." ".
60 &ui_textbox("filter", $p->{'filter'}, 40)."<br>\n".
61 &ui_checkbox("attrs_on", 1, $text{'eacl_attrs'}, $p->{'attrs'})." ".
62 &ui_textbox("attrs", $p->{'attrs'}, 40) );
65 @tds = ( "width=40% nowrap", "width=30%", "width=30%" );
66 $wtable = &ui_columns_start([ $text{'eacl_who'},
68 $text{'eacl_control'} ], 100, 0, \@tds);
70 foreach $b (@{$p->{'by'}}, { }, { }, { }) {
71 $kwho = $b->{'who'} eq 'self' || $b->{'who'} eq 'users' ||
72 $b->{'who'} eq 'anonymous' || $b->{'who'} eq '*' ||
74 $kacc = !$b->{'access'} ? 'read' :
75 &indexof($b->{'access'}, @acl_access_levels) >= 0 ?
76 $b->{'access'} : undef;
77 $wtable .= &ui_columns_row([
78 # Who are we granting?
79 &ui_select("wmode_$i",
80 $kwho ? $b->{'who'} : 'other',
82 [ '*', $text{'eacl_every'} ],
83 [ 'self', $text{'eacl_self'} ],
84 [ 'users', $text{'eacl_users'} ],
85 [ 'anonymous', $text{'eacl_anonymous'} ],
86 [ 'other', $text{'eacl_other'} ] ],
88 "style='width:45%' onChange='form.who_$i.disabled = (form.wmode_$i.value != \"other\")'").
89 &ui_textbox("who_$i", $kwho ? "" : $b->{'who'}, 50,
90 $kwho, undef, "style='width:45%'"),
92 # What access level? Show textbox if complex
93 $kacc ? &ui_select("access_$i", $kacc,
94 [ map { [ $_, $text{'access_l'.$_} ] }
95 @acl_access_levels ], 1, 0, 0, 0,
97 : &ui_textbox("access_$i", $b->{'access'}, 20,
98 0, undef, "style='width:90%'"),
101 &ui_textbox("control_$i", join(" ", @{$b->{'control'}}), 30,
102 0, undef, "style='width:90%'"),
106 $wtable .= &ui_columns_end();
107 print &ui_table_row(undef, $wtable, 2);
110 print &ui_table_end();
112 print &ui_form_end([ [ undef, $text{'create'} ] ]);
115 print &ui_form_end([ [ undef, $text{'save'} ],
116 [ 'delete', $text{'delete'} ] ]);
118 &ui_print_footer("edit_acl.cgi", $text{'acl_return'});