Export/LDAP.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 57 CC 6 SCAR 31.7
CC
6
Cov
0%
process_record
42.0
post_processing
2.0
BEGIN
2.0
CRAP 23.8
1 package BBDB::Export::LDAP;
2 use strict;
3 use warnings;
4  
5 our $VERSION = '0.015';
6  
7  
8 use BBDB::Export::LDIF;
9  
10 our @ISA = qw(BBDB::Export);
11  
12 use Data::Dumper;
13  
14  
15 #
16 #_* process_record
17 #
18  
19 sub process_record
20 {
21 my ( $self, $record ) = @_;
22  
23 my ( $text, $data ) = BBDB::Export::LDIF::process_record( $self, $record );
24  
25 my $tmpfile = $self->{'data'}->{'output_file'};
26 return unless $tmpfile;
27  
28 my $dc = $self->{'data'}->{'dc'};
29 return unless $dc;
30  
31 open ( my $out_fh, ">", $tmpfile ) or die "Unable to create temp file $tmpfile";
32  
33 print $out_fh $text;
34  
35 close $out_fh;
36  
37 my $dn = $data->{'dn'};
38  
39 my $ldappass = $self->{'data'}->{'ldappass'};
40 unless ( $ldappass )
41 {
42 $self->error( "ldappass not specified" );
43 die;
44 }
45  
46 $self->info( "Deleting dn: $dn" ) if $self->{'data'}->{'verbose'};
47 $self->run_command( qq(ldapdelete -x -w $ldappass -D "cn=Manager,$dc" "$dn"), 1 );
48  
49 $self->info( "Adding dn: $dn" ) if $self->{'data'}->{'verbose'};
50 my $add_cmd = qq(ldapadd -x -w $ldappass -D "cn=Manager,$dc" -f $tmpfile);
51 $self->run_command( $add_cmd );
52  
53 }
54  
55 #
56 #_* post_processing
57 #
58  
59 sub post_processing
60 {
61 my ( $self, $output ) = @_;
62 return 1;
63 }
64  
65  
66  
67 1;
68  
69