line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#********************************************************************* |
2
|
|
|
|
|
|
|
#*** ResourcePool::Factory::Net::LDAP |
3
|
|
|
|
|
|
|
#*** Copyright (c) 2002,2003 by Markus Winand |
4
|
|
|
|
|
|
|
#*** $Id: LDAP.pm,v 1.5 2003/09/25 17:34:06 mws Exp $ |
5
|
|
|
|
|
|
|
#********************************************************************* |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package ResourcePool::Factory::Net::LDAP; |
8
|
4
|
|
|
4
|
|
856800
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
170
|
|
9
|
4
|
|
|
4
|
|
23
|
use vars qw($VERSION @ISA); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
227
|
|
10
|
4
|
|
|
4
|
|
3092
|
use ResourcePool::Factory; |
|
4
|
|
|
|
|
27808
|
|
|
4
|
|
|
|
|
105
|
|
11
|
4
|
|
|
4
|
|
2421
|
use ResourcePool::Resource::Net::LDAP; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
116
|
|
12
|
4
|
|
|
4
|
|
47
|
use Data::Dumper; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2237
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
push @ISA, "ResourcePool::Factory"; |
15
|
|
|
|
|
|
|
$VERSION = "1.0002"; |
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
|
3894
|
my ($proto) = shift; |
28
|
47
|
|
66
|
|
|
203
|
my $class = ref($proto) || $proto; |
29
|
47
|
|
|
|
|
191
|
my $self = $class->SUPER::new(); |
30
|
|
|
|
|
|
|
|
31
|
47
|
50
|
|
|
|
635
|
if (! exists($self->{host})) { |
32
|
47
|
|
|
|
|
93
|
$self->{host} = shift; |
33
|
47
|
100
|
100
|
|
|
175
|
if (defined $_[0] && ref($_[0]) ne "ARRAY") { |
34
|
5
|
|
|
|
|
10
|
$self->{BindOptions} = []; |
35
|
5
|
|
|
|
|
15
|
$self->{NewOptions} = [@_]; |
36
|
|
|
|
|
|
|
} else { |
37
|
|
|
|
|
|
|
# old syntax, compatiblity... |
38
|
42
|
100
|
|
|
|
104
|
$self->{BindOptions} = defined $_[0]?shift: []; |
39
|
42
|
100
|
|
|
|
110
|
$self->{NewOptions} = defined $_[0]?shift: []; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
47
|
|
|
|
|
108
|
bless($self, $class); |
44
|
|
|
|
|
|
|
|
45
|
47
|
|
|
|
|
133
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub bind($@) { |
49
|
7
|
|
|
7
|
1
|
40
|
my $self = shift; |
50
|
7
|
|
|
|
|
27
|
$self->{BindOptions} = [@_]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub start_tls($@) { |
54
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
55
|
0
|
|
|
|
|
0
|
$self->{start_tlsOptions} = [@_]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub mk_singleton_key($) { |
59
|
26
|
|
|
26
|
1
|
1918
|
my $d = Data::Dumper->new([$_[0]]); |
60
|
26
|
|
|
|
|
726
|
$d->Indent(0); |
61
|
26
|
|
|
|
|
376
|
$d->Terse(1); |
62
|
26
|
|
|
|
|
151
|
return $d->Dump(); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub create_resource($) { |
67
|
2
|
|
|
2
|
1
|
12
|
my ($self) = @_; |
68
|
2
|
|
|
|
|
37
|
return ResourcePool::Resource::Net::LDAP->new($self |
69
|
|
|
|
|
|
|
, $self->{host} |
70
|
|
|
|
|
|
|
, $self->{BindOptions} |
71
|
|
|
|
|
|
|
, $self->{NewOptions} |
72
|
|
|
|
|
|
|
, $self->{start_tlsOptions} |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub info($) { |
77
|
2
|
|
|
2
|
1
|
6
|
my ($self) = @_; |
78
|
2
|
|
|
|
|
56
|
my $dn; |
79
|
|
|
|
|
|
|
|
80
|
2
|
50
|
|
|
|
4
|
if (scalar(@{$self->{BindOptions}}) % 2 == 0) { |
|
2
|
|
|
|
|
14
|
|
81
|
|
|
|
|
|
|
# even numer -> old Net::LDAP->bind syntax |
82
|
2
|
|
|
|
|
3
|
my %h = @{$self->{BindOptions}}; |
|
2
|
|
|
|
|
7
|
|
83
|
2
|
|
|
|
|
6
|
$dn = $h{dn}; |
84
|
|
|
|
|
|
|
} else { |
85
|
|
|
|
|
|
|
# odd numer -> new Net::LDAP->bind syntax |
86
|
0
|
|
|
|
|
0
|
$dn = $self->{BindOptions}->[0]; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
# if dn is still undef -> anonymous bind |
89
|
2
|
50
|
|
|
|
127
|
return (defined $dn? $dn . "@" : "" ) . $self->{host}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |