3 # Ask the LDAP server to return groups matching some query
5 require './ldap-useradmin-lib.pl';
7 &useradmin::load_theme_library(); # So that ui functions work
10 $ldap = &ldap_connect();
11 $base = &get_group_base();
12 if ($in{'match'} == 0) {
13 $search = "($in{'field'}=$in{'what'})";
15 elsif ($in{'match'} == 1) {
16 $search = "($in{'field'}=*$in{'what'}*)";
18 elsif ($in{'match'} == 2) {
19 $search = "(!($in{'field'}=$in{'what'}))";
21 elsif ($in{'match'} == 3) {
22 $search = "(!($in{'field'}=*$in{'what'}*))";
24 $rv = $ldap->search(base => $base,
25 filter => "(&".&group_filter().$search.")");
27 &error(&text('search_err', "<tt>$search</tt>",
28 "<tt>$base</tt>", $rv->error));
30 @groups = $rv->all_entries;
32 if ($in{'match'} == 6) {
33 # Apply less-than filter manually
34 @groups = grep { $_->get_value($in{'field'}) < $in{'what'} } @groups;
36 elsif ($in{'match'} == 7) {
37 # Apply greater-than filter manually
38 @groups = grep { $_->get_value($in{'field'}) > $in{'what'} } @groups;
41 &ui_print_header(undef, $text{'search_title'}, "");
43 print "<p><b>$text{'search_gnotfound'}</b>.<p>\n";
46 @glist = map { { &dn_to_hash($_) } } @groups;
47 &useradmin::groups_table(\@glist, 0, 1);
49 &ui_print_footer("", $text{'index_return'});