aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Commands/search_domain.pm
blob: 9c47d435c92a37a2f6d4daf1c614a3df78326ceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package Fripost::Commands::search_domain;

use 5.010_000;
use strict;
use warnings;
use utf8;

=head1 NAME

search_domain.pm - List matching virtual domains

=cut

use FindBin qw($Bin);
use lib "$Bin/lib";

use Fripost::Schema;

our $VERSION = '0.01';

sub main {
    my $ldap = shift;
    my $conf = shift;

    my %domain;
    $domain{domain} = $_[0] if defined $_[0];
    $domain{owner}  = $_[1] if defined $_[1];
    
    foreach my $domain ($ldap->domain->search( \%domain )->entries) {
        say '' . ($domain->{isActive} ? 'ACTIVE' : 'INACTIVE')
            . ' domain ' . $domain->{domain}
            . ' is owned by '
            . (defined $domain->{owner} ? join ', ', @{$domain->{owner}}
                                        : '(none)');
    }
}


=head1 AUTHOR

Guilhem Moulin C<< <guilhem at fripost.org> >>

=head1 COPYRIGHT

Copyright 2012 Guilhem Moulin.

=head1 LICENSE

This program is free software; you can redistribute it and/or modify it
under the same terms as perl itself.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

=cut

1; # End of search_domain.pm

__END__