line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#********************************************************************* |
2
|
|
|
|
|
|
|
#*** ResourcePool::Factory::Net::LDAP |
3
|
|
|
|
|
|
|
#*** Copyright (c) 2020 by Markus Winand |
4
|
|
|
|
|
|
|
#*** $Id$ |
5
|
|
|
|
|
|
|
#********************************************************************* |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package ResourcePool::Factory::Net::LDAP; |
8
|
4
|
|
|
4
|
|
684858
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
114
|
|
9
|
4
|
|
|
4
|
|
20
|
use vars qw($VERSION @ISA); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
197
|
|
10
|
4
|
|
|
4
|
|
1525
|
use ResourcePool::Factory; |
|
4
|
|
|
|
|
10774
|
|
|
4
|
|
|
|
|
97
|
|
11
|
4
|
|
|
4
|
|
1488
|
use ResourcePool::Resource::Net::LDAP; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
104
|
|
12
|
4
|
|
|
4
|
|
24
|
use Data::Dumper; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1362
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
push @ISA, "ResourcePool::Factory"; |
15
|
|
|
|
|
|
|
$VERSION = "1.0003"; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#### |
18
|
|
|
|
|
|
|
# Some notes about the singleton behavior of this class. |
19
|
|
|
|
|
|
|
# 1. the constructor does not return a singleton reference! |
20
|
|
|
|
|
|
|
# 2. there is a seperate function called singelton() which will return a |
21
|
|
|
|
|
|
|
# singleton reference |
22
|
|
|
|
|
|
|
# this change was introduces with ResourcePool 0.9909 to allow more flexible |
23
|
|
|
|
|
|
|
# factories (e.g. factories which do not require all parameters to their |
24
|
|
|
|
|
|
|
# constructor) an example of such an factory is the Net::LDAP factory. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new($@) { |
27
|
47
|
|
|
47
|
1
|
5071
|
my ($proto) = shift; |
28
|
47
|
|
66
|
|
|
153
|
my $class = ref($proto) || $proto; |
29
|
47
|
|
|
|
|
115
|
my $self = $class->SUPER::new(); |
30
|
|
|
|
|
|
|
|
31
|
47
|
50
|
|
|
|
522
|
if (! exists($self->{host})) { |
32
|
47
|
|
|
|
|
75
|
$self->{host} = shift; |
33
|
47
|
100
|
100
|
|
|
116
|
if (defined $_[0] && ref($_[0]) ne "ARRAY") { |
34
|
5
|
|
|
|
|
22
|
$self->{BindOptions} = []; |
35
|
5
|
|
|
|
|
14
|
$self->{NewOptions} = [@_]; |
36
|
|
|
|
|
|
|
} else { |
37
|
|
|
|
|
|
|
# old syntax, compatiblity... |
38
|
42
|
100
|
|
|
|
74
|
$self->{BindOptions} = defined $_[0]?shift: []; |
39
|
42
|
100
|
|
|
|
77
|
$self->{NewOptions} = defined $_[0]?shift: []; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
47
|
|
|
|
|
64
|
bless($self, $class); |
44
|
|
|
|
|
|
|
|
45
|
47
|
|
|
|
|
115
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub bind($@) { |
49
|
7
|
|
|
7
|
0
|
22
|
my $self = shift; |
50
|
7
|
|
|
|
|
17
|
$self->{BindOptions} = [@_]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub start_tls($@) { |
54
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
55
|
0
|
|
|
|
|
0
|
$self->{start_tlsOptions} = [@_]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub create_resource($) { |
59
|
2
|
|
|
2
|
1
|
10
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
return ResourcePool::Resource::Net::LDAP->new($self |
61
|
|
|
|
|
|
|
, $self->{host} |
62
|
|
|
|
|
|
|
, $self->{BindOptions} |
63
|
|
|
|
|
|
|
, $self->{NewOptions} |
64
|
|
|
|
|
|
|
, $self->{start_tlsOptions} |
65
|
2
|
|
|
|
|
16
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub info($) { |
69
|
2
|
|
|
2
|
1
|
6
|
my ($self) = @_; |
70
|
2
|
|
|
|
|
17
|
my $dn; |
71
|
|
|
|
|
|
|
|
72
|
2
|
50
|
|
|
|
4
|
if (scalar(@{$self->{BindOptions}}) % 2 == 0) { |
|
2
|
|
|
|
|
13
|
|
73
|
|
|
|
|
|
|
# even numer -> old Net::LDAP->bind syntax |
74
|
2
|
|
|
|
|
6
|
my %h = @{$self->{BindOptions}}; |
|
2
|
|
|
|
|
8
|
|
75
|
2
|
|
|
|
|
6
|
$dn = $h{dn}; |
76
|
|
|
|
|
|
|
} else { |
77
|
|
|
|
|
|
|
# odd numer -> new Net::LDAP->bind syntax |
78
|
0
|
|
|
|
|
0
|
$dn = $self->{BindOptions}->[0]; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
# if dn is still undef -> anonymous bind |
81
|
2
|
50
|
|
|
|
17
|
return (defined $dn? $dn . "@" : "" ) . $self->{host}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |