| 1 | package App::LDAP::Command::Export; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Modern::Perl; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | with qw( App::LDAP::Role::Command | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | App::LDAP::Role::Bindable ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | has base => ( | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | has scope => ( | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | has filter => ( | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $file = $self->extra_argv->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if (! defined($file)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | say "you must give the file name to export"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | my @entries = ldap()->search( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | base => $self->base // config()->{base}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | scope => $self->scope // config()->{scope}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | filter => $self->filter // "objectClass=*", | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$self->base // config()->{"base"}
$self->scope // config()->{"scope"}
$self->filter // "objectClass=*"
MC/DC0%0/2
$self->base // config()->{"base"}
$self->base
config()->{"base"}
MC/DC0%0/2
$self->scope // config()->{"scope"}
$self->scope
config()->{"scope"}
MC/DC0%0/1
$self->filter // "objectClass=*"
$self->filter
Truth table0%0/3
A // B
A= $self->baseB= config()->{"base"}
Truth table0%0/3
A // B
A= $self->scopeB= config()->{"scope"}
Truth table0%0/2
A
A= $self->filter
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | )->entries; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | open my $output, ">", $file or die "can not open $file"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | for (@entries) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | print $output $_->ldif; | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | App::LDAP::Command::Export | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $ sudo ldap export backup.ldif | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | backup whole DIT | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | $ ldap export people.ldif --base ou=people,dc=example,dc=com | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | dump user information without password | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $ sudo ldap export people.ldif --base ou=people,dc=example,dc=com | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | dump user information with password | ||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||