X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=mutt-licom.pl;h=e7fbcbdd71062e3828e855d48baee4f7111fa5dc;hb=3cb23a820a52afa74acedf88975edf7920ae66f9;hp=894bd1eb8bedd01072a1917f086716d666ffa2be;hpb=668385f6b26d5280882b020656034d701157fb02;p=licom.git diff --git a/mutt-licom.pl b/mutt-licom.pl index 894bd1e..e7fbcbd 100755 --- a/mutt-licom.pl +++ b/mutt-licom.pl @@ -2,15 +2,42 @@ use strict; use warnings; -use lib (qw(lib)); + +use FindBin (qw($Bin)); +use lib ("$Bin/lib"); use LiCoM::Config (qw(get_config)); use LiCoM::Person; -our $Config = get_config (); +our $Config; -die unless (defined ($Config->{'uri'}) and defined ($Config->{'bind_dn'}) - and defined ($Config->{'password'})); +if (-e $ENV{'HOME'} . '/.licomrc') +{ + $Config = get_config ($ENV{'HOME'} . '/.licomrc'); +} +elsif (-e '/etc/licom/licom.conf') +{ + $Config = get_config ('/etc/licom/licom.conf'); +} +else +{ + $Config = get_config (); +} + +if ($ENV{'DEBUG'}) +{ + require Data::Dumper; + print STDERR Data::Dumper->Dump ([$Config], ['Config']); +} + +unless (defined ($Config->{'uri'}) and defined ($Config->{'bind_dn'}) + and defined ($Config->{'password'})) +{ + die (<{'base_dn'} = $Config->{'bind_dn'} unless (defined ($Config->{'base_dn'})); @@ -28,19 +55,31 @@ for (@ARGV) die ('No (valid) patterns found.') unless (@Patterns); +LiCoM::Person->connect +( + uri => $Config->{'uri'}, + base_dn => $Config->{'base_dn'}, + bind_dn => $Config->{'bind_dn'}, + password => $Config->{'password'} +) or die; + our @Matches = LiCoM::Person->search (@Patterns, [[mail => '*']]); print STDOUT scalar (@Matches), ' ', (scalar (@Matches) == 1 ? 'entry' : 'entries'), " found.\n"; -for (@Matches) +for (sort { $a->name () cmp $b->name () } (@Matches)) { my $person = $_; my $cn = $person->name (); my @mail = $person->get ('mail'); + my @groups = $person->get ('group'); + my $info = join (', ', sort (@groups)); + + $info = "($info)" if ($info); - for (@mail) + for (sort (@mail)) { - print "$_\t$cn\tFound by LiCoM\n"; + print "$_\t$cn\t$info\n"; } }