2 # Show the LDAP tree in a popup browser window, for selecting something
4 $trust_unknown_referers = 1;
5 require './ldap-client-lib.pl';
6 &popup_header($text{'browser_title'});
9 # Connect to LDAP server, or die trying
10 $ldap = &ldap_connect(1);
12 print &text('browser_econn', $ldap),"<p>\n";
17 # Work out the base (current navigation level)
19 $base = $in{'parent'};
21 elsif (!$in{'base'}) {
22 $conf = &get_config();
23 $base = &find_value("base", $conf);
29 # Javascript to update original field
31 print "function ldap_select(f)\n";
33 print "top.opener.ifield.value = f;\n";
34 print "top.close();\n";
35 print "window.close();\n";
36 print "return false;\n";
40 # Find the actual base object
41 $rv2 = $ldap->search(base => $base,
42 filter => '(objectClass=*)',
45 ($bo) = $rv2->all_entries;
46 ($top) = grep { $_ eq "top" } $bo->get_value("objectClass");
49 # Show current base (with option to change), and parent button
50 print &ui_form_start("popup_browser.cgi"),"\n";
51 print &ui_hidden("node", $in{'node'}),"\n";
52 print "<b>$text{'browser_base'}</b>\n";
53 print &ui_textbox("base", $base, 40)," ",&ui_submit($text{'browser_ok'}),"\n";
55 $parent =~ s/^[^,]+,\s*//;
57 # Show the OK button only if the object type is appropriatye
58 if ($in{'node'} == 0 && $top ||
59 $in{'node'} == 1 && !$top ||
61 print "<input type=button onClick='return ldap_select(\"".
62 "e_escape($base, '"'),"\")' ",
63 "value='$text{'browser_sel'}'>\n";
68 $rv = $ldap->search(base => $base,
69 filter => '(objectClass=*)',
73 print &text('browser_esearch', $rv->error),"<p>\n";
78 print "<table width=100%>\n";
79 if ($parent =~ /\S/) {
80 print "<tr> <td><i><a href='popup_browser.cgi?node=".
81 &urlize($in{'node'})."&base=",
82 &urlize($parent),"'><img src=images/up.gif border=0> ",
83 &html_escape($parent),"</a></td> </tr>\n";
85 if ($rv->all_entries) {
86 # If this object has sub-objects, show them
87 foreach $dn (sort { lc($a->dn()) cmp lc($b->dn()) } $rv->all_entries) {
88 print "<tr> <td><a href='popup_browser.cgi?node=".
89 &urlize($in{'node'}),"&",
90 "base=".&urlize($dn->dn()).
91 "'><img src=images/open.gif border=0>",
92 " ",&html_escape($dn->dn()),"</a></td> </tr>\n";
97 foreach $a (sort { lc($a) cmp lc($b) } $bo->attributes()) {
98 @v = $bo->get_value($a);
99 print "<tr> <td>$a</td> <td>:</td> <td>",
100 join(" , ", @v),"</td> </tr>\n";