« blib/lib/Lemonldap/NG/Common/Session/REST.pm
↑ Summary
blib/lib/Lemonldap/NG/Common/Conf/RESTServer.pm »
| 1 | ##@file | ||||||||||||||||||||||||||||
| 2 | # LDAP configuration backend | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | ##@class | ||||||||||||||||||||||||||||
| 5 | # Implements LDAP backend for Lemonldap::NG | ||||||||||||||||||||||||||||
| 6 | package Lemonldap::NG::Common::Conf::Backends::LDAP; | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Net::LDAP; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Lemonldap::NG::Common::Conf::Constants; #inherits | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Lemonldap::NG::Common::Conf::Serializer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '2.23.0'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | *Lemonldap::NG::Common::Conf::getLdapConnection = \&getLdapConnection; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub prereq { | ||||||||||||||||||||||||||
|
Subroutine
prereq: called CC=6 SCAR=20.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 22 | 1 | foreach ( 'ldapServer', 'ldapConfBase', 'ldapBindDN', 'ldapBindPassword' ) { | |||||||||||||||||||||||||||
| 23 | 4 | ▶ | unless ( $self->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | $Lemonldap::NG::Common::Conf::msg .= | |||||||||||||||||||||||||||
| 25 | "$_ is required in LDAP configuration type \n"; | ||||||||||||||||||||||||||||
| 26 | 0 | return 0; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 1 | ▶ | $self->{ldapObjectClass} ||= "applicationProcess"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"ldapObjectClass"} ||= "applicationProcess"
$self->{"ldapObjectClass"}
Truth table50%1/2
A
A= $self->{"ldapObjectClass"}
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | $self->{ldapAttributeId} ||= "cn"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"ldapAttributeId"} ||= "cn"
$self->{"ldapAttributeId"}
Truth table50%1/2
A
A= $self->{"ldapAttributeId"}
| |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | $self->{ldapAttributeContent} ||= "description"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"ldapAttributeContent"} ||= "description"
$self->{"ldapAttributeContent"}
Truth table50%1/2
A
A= $self->{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||
| 32 | 1 | 1; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub available { | ||||||||||||||||||||||||||
|
Subroutine
available: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $ldap = $self->getLdapConnection; | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless ($ldap) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | return 0; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | my $search = $ldap->search( | ||||||||||||||||||||||||||||
| 44 | base => $self->{ldapConfBase}, | ||||||||||||||||||||||||||||
| 45 | filter => '(objectClass=' . $self->{ldapObjectClass} . ')', | ||||||||||||||||||||||||||||
| 46 | scope => 'one', | ||||||||||||||||||||||||||||
| 47 | 0 | attrs => [ $self->{ldapAttributeId} ], | |||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | 0 | $ldap->unbind; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( $search->code ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $self->logError($search); | |||||||||||||||||||||||||||
| 53 | 0 | return 0; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | my @entries = $search->entries(); | |||||||||||||||||||||||||||
| 57 | 0 | my @conf; | |||||||||||||||||||||||||||
| 58 | 0 | foreach (@entries) { | |||||||||||||||||||||||||||
| 59 | 0 | my $cn = $_->get_value( $self->{ldapAttributeId} ); | |||||||||||||||||||||||||||
| 60 | 0 | my ($cfgNum) = ( $cn =~ /lmConf-(\d*)/ ); | |||||||||||||||||||||||||||
| 61 | 0 | push @conf, $cfgNum; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 0 | return sort { $a <=> $b } @conf; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub lastCfg { | ||||||||||||||||||||||||||
|
Subroutine
lastCfg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 68 | 0 | my @avail = $self->available; | |||||||||||||||||||||||||||
| 69 | 0 | return $avail[$#avail]; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub getLdapConnection { | ||||||||||||||||||||||||||
|
Subroutine
getLdapConnection: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | # Parse servers configuration | ||||||||||||||||||||||||||||
| 76 | 0 | my $useTls = 0; | |||||||||||||||||||||||||||
| 77 | 0 | my $tlsParam; | |||||||||||||||||||||||||||
| 78 | 0 | my @servers = (); | |||||||||||||||||||||||||||
| 79 | 0 | foreach my $server ( split /[\s,]+/, $self->{ldapServer} ) { | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $server =~ m{^ldap\+tls://([^/]+)/?\??(.*)$} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $useTls = 1; | |||||||||||||||||||||||||||
| 82 | 0 | $server = $1; | |||||||||||||||||||||||||||
| 83 | 0 | ▶ | $tlsParam = $2 || ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$2 || ''
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||
| 86 | 0 | $useTls = 0; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 0 | push @servers, $server; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # Connect | ||||||||||||||||||||||||||||
| 92 | my $ldap = Net::LDAP->new( | ||||||||||||||||||||||||||||
| 93 | \@servers, | ||||||||||||||||||||||||||||
| 94 | keepalive => 1, | ||||||||||||||||||||||||||||
| 95 | onerror => undef, | ||||||||||||||||||||||||||||
| 96 | verify => ( $self->{ldapVerify} || "require" ), | ||||||||||||||||||||||||||||
| 97 | ( $self->{ldapCAFile} ? ( cafile => $self->{ldapCAFile} ) : () ), | ||||||||||||||||||||||||||||
| 98 | ( $self->{ldapCAPath} ? ( capath => $self->{ldapCAPath} ) : () ), | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | ( $self->{ldapPort} ? ( port => $self->{ldapPort} ) : () ), | ||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/2
$self->{'ldapVerify'} || 'require'
MC/DC0%0/1
$self->{'ldapVerify'} || 'require'
$self->{'ldapVerify'}
Truth table0%0/2
A
A= $self->{'ldapVerify'}
| |||||||||||||||||||||||||||||
| 100 | raw => qr/(?i:^jpegPhoto|;binary)/ | ||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | unless ($ldap) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 104 | 0 | $Lemonldap::NG::Common::Conf::msg .= "$@\n"; | |||||||||||||||||||||||||||
| 105 | 0 | return; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 0 | elsif ( $Net::LDAP::VERSION < '0.64' ) { | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | # CentOS7 has a bug in which IO::Socket::SSL will return a broken | ||||||||||||||||||||||||||||
| 110 | # socket when certificate validation fails. Net::LDAP does not catch | ||||||||||||||||||||||||||||
| 111 | # it, and the process ends up crashing. | ||||||||||||||||||||||||||||
| 112 | # As a precaution, make sure the underlying socket is doing fine: | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( $ldap->socket->isa('IO::Socket::SSL') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ldap->socket->isa("IO::Socket::SSL") and $ldap->socket->errstr < 0
MC/DC0%0/2
$ldap->socket->isa("IO::Socket::SSL") and $ldap->socket->errstr < 0
$ldap->socket->isa("IO::Socket::SSL")
$ldap->socket->errstr < 0
Truth table0%0/3
A and B
A= $ldap->socket->isa("IO::Socket::SSL")B= $ldap->socket->errstr < 0
| |||||||||||||||||||||||||||||
| 114 | and $ldap->socket->errstr < 0 ) | ||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||
| 116 | 0 | $Lemonldap::NG::Common::Conf::msg .= | |||||||||||||||||||||||||||
| 117 | "SSL connection error: " . $ldap->socket->errstr; | ||||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # Start TLS if needed | ||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ($useTls) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | my %h = split( /[&=]/, $tlsParam ); | |||||||||||||||||||||||||||
| 125 | 0 | ▶ | $h{verify} ||= $self->{ldapVerify} || "require"; | ||||||||||||||||||||||||||
|
Condition0%0/5
$h{"verify"} ||= $self->{"ldapVerify"} || "require"
$self->{'ldapVerify'} || 'require'
MC/DC0%0/2
$h{"verify"} ||= $self->{"ldapVerify"} || "require"
$h{"verify"}
$self->{'ldapVerify'}
Truth table0%0/3
A ||= B
A= $h{"verify"}B= $self->{'ldapVerify'}
| |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $h{cafile} ||= $self->{ldapCAFile} if ( $self->{ldapCAFile} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h{"cafile"} ||= $self->{"ldapCAFile"}
MC/DC0%0/2
$h{"cafile"} ||= $self->{"ldapCAFile"}
$h{"cafile"}
$self->{"ldapCAFile"}
Truth table0%0/3
A ||= B
A= $h{"cafile"}B= $self->{"ldapCAFile"}
| |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $h{capath} ||= $self->{ldapCAPath} if ( $self->{ldapCAPath} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h{"capath"} ||= $self->{"ldapCAPath"}
MC/DC0%0/2
$h{"capath"} ||= $self->{"ldapCAPath"}
$h{"capath"}
$self->{"ldapCAPath"}
Truth table0%0/3
A ||= B
A= $h{"capath"}B= $self->{"ldapCAPath"}
| |||||||||||||||||||||||||||||
| 128 | 0 | my $start_tls = $ldap->start_tls(%h); | |||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( $start_tls->code ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | $self->logError($start_tls); | |||||||||||||||||||||||||||
| 131 | 0 | return; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # Bind with credentials | ||||||||||||||||||||||||||||
| 136 | my $bind = | ||||||||||||||||||||||||||||
| 137 | 0 | $ldap->bind( $self->{ldapBindDN}, password => $self->{ldapBindPassword} ); | |||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ( $bind->code ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | 0 | $self->logError($bind); | |||||||||||||||||||||||||||
| 140 | 0 | return; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | return $ldap; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub lock { | ||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | # No lock for LDAP | ||||||||||||||||||||||||||||
| 149 | 0 | return 1; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub isLocked { | ||||||||||||||||||||||||||
|
Subroutine
isLocked: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | # No lock for LDAP | ||||||||||||||||||||||||||||
| 155 | 0 | return 0; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub unlock { | ||||||||||||||||||||||||||
|
Subroutine
unlock: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | # No lock for LDAP | ||||||||||||||||||||||||||||
| 161 | 0 | return 1; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub store { | ||||||||||||||||||||||||||
|
Subroutine
store: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 165 | 0 | my ( $self, $fields ) = @_; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | my $ldap = $self->getLdapConnection; | |||||||||||||||||||||||||||
| 168 | 0 | ▶ | unless ($ldap) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | return 0; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | $fields = $self->serialize($fields); | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | my $lastCfg = $self->lastCfg; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | my $confName = "lmConf-" . $fields->{cfgNum}; | |||||||||||||||||||||||||||
| 177 | my $confDN = | ||||||||||||||||||||||||||||
| 178 | 0 | $self->{ldapAttributeId} . "=$confName," . $self->{ldapConfBase}; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | # Store values as {key}value | ||||||||||||||||||||||||||||
| 181 | 0 | my @confValues; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | while ( my ( $k, $v ) = each(%$fields) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | push @confValues, "{$k}$v"; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | my $operation; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ( $lastCfg == $fields->{cfgNum} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | $operation = | ||||||||||||||||||||||||||||
| 190 | $ldap->modify( $confDN, | ||||||||||||||||||||||||||||
| 191 | 0 | replace => { $self->{ldapAttributeContent} => \@confValues } ); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | else { | ||||||||||||||||||||||||||||
| 194 | $operation = $ldap->add( | ||||||||||||||||||||||||||||
| 195 | $confDN, | ||||||||||||||||||||||||||||
| 196 | attrs => [ | ||||||||||||||||||||||||||||
| 197 | objectClass => [ 'top', $self->{ldapObjectClass} ], | ||||||||||||||||||||||||||||
| 198 | $self->{ldapAttributeId} => $confName, | ||||||||||||||||||||||||||||
| 199 | 0 | $self->{ldapAttributeContent} => \@confValues, | |||||||||||||||||||||||||||
| 200 | ] | ||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | 0 | $ldap->unbind; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( $operation->code ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | $self->logError($operation); | |||||||||||||||||||||||||||
| 207 | 0 | return 0; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | return $fields->{cfgNum}; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 214 | 0 | my ( $self, $cfgNum, $fields ) = @_; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | my $ldap = $self->getLdapConnection; | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | unless ($ldap) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 0 | return; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | my $f; | |||||||||||||||||||||||||||
| 222 | 0 | my $confName = "lmConf-" . $cfgNum; | |||||||||||||||||||||||||||
| 223 | my $confDN = | ||||||||||||||||||||||||||||
| 224 | 0 | $self->{ldapAttributeId} . "=$confName," . $self->{ldapConfBase}; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | my $search = $ldap->search( | ||||||||||||||||||||||||||||
| 227 | base => $confDN, | ||||||||||||||||||||||||||||
| 228 | filter => '(objectClass=' . $self->{ldapObjectClass} . ')', | ||||||||||||||||||||||||||||
| 229 | scope => 'base', | ||||||||||||||||||||||||||||
| 230 | 0 | attrs => [ $self->{ldapAttributeContent} ], | |||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||
| 232 | 0 | $ldap->unbind; | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if ( $search->code ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 0 | $self->logError($search); | |||||||||||||||||||||||||||
| 236 | 0 | return; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | my $entry = $search->shift_entry(); | |||||||||||||||||||||||||||
| 240 | 0 | my @confValues = $entry->get_value( $self->{ldapAttributeContent} ); | |||||||||||||||||||||||||||
| 241 | 0 | foreach (@confValues) { | |||||||||||||||||||||||||||
| 242 | 0 | my ( $k, $v ) = ( $_ =~ /\{(.*?)\}(.*)/s ); | |||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ($fields) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $f->{$k} = $v if ( grep { $_ eq $k } @$fields ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | else { | ||||||||||||||||||||||||||||
| 247 | 0 | $f->{$k} = $v; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | 0 | return $self->unserialize($f); | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 254 | 0 | my ( $self, $cfgNum ) = @_; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | my $ldap = $self->getLdapConnection; | |||||||||||||||||||||||||||
| 257 | 0 | ▶ | unless ($ldap) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | return 0; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | my $confDN = | ||||||||||||||||||||||||||||
| 262 | $self->{ldapAttributeId} | ||||||||||||||||||||||||||||
| 263 | . "=lmConf-" | ||||||||||||||||||||||||||||
| 264 | . $cfgNum . "," | ||||||||||||||||||||||||||||
| 265 | 0 | . $self->{ldapConfBase}; | |||||||||||||||||||||||||||
| 266 | 0 | my $delete = $ldap->delete($confDN); | |||||||||||||||||||||||||||
| 267 | 0 | $ldap->unbind; | |||||||||||||||||||||||||||
| 268 | 0 | ▶ | $self->logError($delete) if ( $delete->code ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub logError { | ||||||||||||||||||||||||||
|
Subroutine
logError: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 272 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 273 | 0 | my $ldap_operation = shift; | |||||||||||||||||||||||||||
| 274 | 0 | $Lemonldap::NG::Common::Conf::msg .= | |||||||||||||||||||||||||||
| 275 | "LDAP error " | ||||||||||||||||||||||||||||
| 276 | . $ldap_operation->code . ": " | ||||||||||||||||||||||||||||
| 277 | . $ldap_operation->error . " \n"; | ||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 1 | 1; | |||||||||||||||||||||||||||
| 281 | __END__ | ||||||||||||||||||||||||||||