| 1 | package App::LDAP::Command::Import; | ||||||||||
| 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 | ▶ | use Net::LDAP::LDIF; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 13 | 0 | my ($self) = shift; | |||||||||
| 14 | |||||||||||
| 15 | 0 | shift @ARGV; | |||||||||
| 16 | 0 | process($_) for @ARGV; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | sub process { | ||||||||
|
Subroutine
process: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 20 | 0 | my ($file) = @_; | |||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | if (-f $file) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 0 | say "import $file..."; | |||||||||
| 25 | |||||||||||
| 26 | 0 | my $ldif = Net::LDAP::LDIF->new($file, "r", onerror => 'die'); | |||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | while (!$ldif->eof) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | my $entry = $ldif->read_entry; | |||||||||
| 30 | 0 | my $msg = ldap()->add($entry); | |||||||||
| 31 | 0 | ▶ | warn $msg->error() if $msg->code; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | } else { | ||||||||||
| 35 | 0 | say "$_ don\'t exist. skip."; | |||||||||
| 36 | 0 | return; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | |||||||||||
| 43 | =pod | ||||||||||
| 44 | |||||||||||
| 45 | =head1 NAME | ||||||||||
| 46 | |||||||||||
| 47 | App::LDAP::Command::Import | ||||||||||
| 48 | |||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||
| 50 | |||||||||||
| 51 | $ ldap import people.ldif | ||||||||||
| 52 | |||||||||||
| 53 | =cut | ||||||||||