6 use FindBin (qw($Bin));
9 use LiCoM::Config (qw(get_config));
14 if (-e $ENV{'HOME'} . '/.licomrc')
16 $Config = get_config ($ENV{'HOME'} . '/.licomrc');
18 elsif (-e '/etc/licom/licom.conf')
20 $Config = get_config ('/etc/licom/licom.conf');
24 $Config = get_config ();
30 print STDERR Data::Dumper->Dump ([$Config], ['Config']);
33 unless (defined ($Config->{'uri'}) and defined ($Config->{'bind_dn'})
34 and defined ($Config->{'password'}))
37 The configuration has not been found or is not complete. At least the options
38 uri, bind_dn and password are needed.
42 $Config->{'base_dn'} = $Config->{'bind_dn'} unless (defined ($Config->{'base_dn'}));
48 $temp =~ s/[^\.\*\w\s]//g;
53 push (@Patterns, [[lastname => $temp], [firstname => $temp], [mail => $temp]]);
56 die ('No (valid) patterns found.') unless (@Patterns);
58 LiCoM::Person->connect
60 uri => $Config->{'uri'},
61 base_dn => $Config->{'base_dn'},
62 bind_dn => $Config->{'bind_dn'},
63 password => $Config->{'password'}
66 our @Matches = LiCoM::Person->search (@Patterns, [[mail => '*']]);
68 print STDOUT scalar (@Matches), ' ', (scalar (@Matches) == 1 ? 'entry' : 'entries'), " found.\n";
70 for (sort { $a->name () cmp $b->name () } (@Matches))
73 my $cn = $person->name ();
74 my @mail = $person->get ('mail');
75 my @groups = $person->get ('group');
76 my $info = join (', ', sort (@groups));
78 $info = "($info)" if ($info);
82 print "$_\t$cn\t$info\n";
86 LiCoM::Person->disconnect ();