line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 1999-2004 Graham Barr . All rights reserved. |
2
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
3
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::LDAP::Control; |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
43
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
300
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
|
|
5526
|
use Net::LDAP::Constant qw( |
10
|
|
|
|
|
|
|
LDAP_CONTROL_SORTREQUEST |
11
|
|
|
|
|
|
|
LDAP_CONTROL_SORTRESULT |
12
|
|
|
|
|
|
|
LDAP_CONTROL_VLVREQUEST |
13
|
|
|
|
|
|
|
LDAP_CONTROL_VLVRESPONSE |
14
|
|
|
|
|
|
|
LDAP_CONTROL_PAGED |
15
|
|
|
|
|
|
|
LDAP_CONTROL_PROXYAUTHORIZATION |
16
|
|
|
|
|
|
|
LDAP_CONTROL_MANAGEDSAIT |
17
|
|
|
|
|
|
|
LDAP_CONTROL_PERSISTENTSEARCH |
18
|
|
|
|
|
|
|
LDAP_CONTROL_ENTRYCHANGE |
19
|
|
|
|
|
|
|
LDAP_CONTROL_MATCHEDVALUES |
20
|
|
|
|
|
|
|
LDAP_CONTROL_PASSWORDPOLICY |
21
|
|
|
|
|
|
|
LDAP_CONTROL_PREREAD |
22
|
|
|
|
|
|
|
LDAP_CONTROL_POSTREAD |
23
|
|
|
|
|
|
|
LDAP_CONTROL_SYNC |
24
|
|
|
|
|
|
|
LDAP_CONTROL_SYNC_STATE |
25
|
|
|
|
|
|
|
LDAP_CONTROL_SYNC_DONE |
26
|
|
|
|
|
|
|
LDAP_CONTROL_ASSERTION |
27
|
|
|
|
|
|
|
LDAP_CONTROL_RELAX |
28
|
|
|
|
|
|
|
LDAP_CONTROL_DONTUSECOPY |
29
|
|
|
|
|
|
|
LDAP_CONTROL_TREE_DELETE |
30
|
6
|
|
|
6
|
|
33
|
); |
|
6
|
|
|
|
|
19
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my %Pkg2Type = ( |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
'Net::LDAP::Control::Sort' => LDAP_CONTROL_SORTREQUEST, |
37
|
|
|
|
|
|
|
'Net::LDAP::Control::SortResult' => LDAP_CONTROL_SORTRESULT, |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
'Net::LDAP::Control::VLV' => LDAP_CONTROL_VLVREQUEST, |
40
|
|
|
|
|
|
|
'Net::LDAP::Control::VLVResponse' => LDAP_CONTROL_VLVRESPONSE, |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
'Net::LDAP::Control::Paged' => LDAP_CONTROL_PAGED, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
'Net::LDAP::Control::ProxyAuth' => LDAP_CONTROL_PROXYAUTHORIZATION, |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
'Net::LDAP::Control::ManageDsaIT' => LDAP_CONTROL_MANAGEDSAIT, |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
'Net::LDAP::Control::PersistentSearch' => LDAP_CONTROL_PERSISTENTSEARCH, |
49
|
|
|
|
|
|
|
'Net::LDAP::Control::EntryChange' => LDAP_CONTROL_ENTRYCHANGE, |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
'Net::LDAP::Control::MatchedValues' => LDAP_CONTROL_MATCHEDVALUES, |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
'Net::LDAP::Control::PasswordPolicy' => LDAP_CONTROL_PASSWORDPOLICY, |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
'Net::LDAP::Control::PreRead' => LDAP_CONTROL_PREREAD, |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
'Net::LDAP::Control::PostRead' => LDAP_CONTROL_POSTREAD, |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
'Net::LDAP::Control::SyncRequest' => LDAP_CONTROL_SYNC, |
60
|
|
|
|
|
|
|
'Net::LDAP::Control::SyncState' => LDAP_CONTROL_SYNC_STATE, |
61
|
|
|
|
|
|
|
'Net::LDAP::Control::SyncDone' => LDAP_CONTROL_SYNC_DONE, |
62
|
|
|
|
|
|
|
'Net::LDAP::Control::Assertion' => LDAP_CONTROL_ASSERTION, |
63
|
|
|
|
|
|
|
'Net::LDAP::Control::Relax' => LDAP_CONTROL_RELAX, |
64
|
|
|
|
|
|
|
'Net::LDAP::Control::DontUseCopy' => LDAP_CONTROL_DONTUSECOPY, |
65
|
|
|
|
|
|
|
'Net::LDAP::Control::TreeDelete' => LDAP_CONTROL_TREE_DELETE, |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
#LDAP_CONTROL_PWEXPIRED |
68
|
|
|
|
|
|
|
#LDAP_CONTROL_PWEXPIRING |
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
#LDAP_CONTROL_REFERRALS |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my %Type2Pkg = reverse %Pkg2Type; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub register { |
76
|
0
|
|
|
0
|
1
|
0
|
my($class, $oid) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
require Carp and Carp::croak("$oid is already registered to $Type2Pkg{$oid}") |
79
|
0
|
0
|
0
|
|
|
0
|
if exists $Type2Pkg{$oid} and $Type2Pkg{$oid} ne $class; |
|
|
|
0
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
require Carp and Carp::croak("$class is already registered to $Pkg2Type{$class}") |
82
|
0
|
0
|
0
|
|
|
0
|
if exists $Pkg2Type{$class} and $Pkg2Type{$class} ne $oid; |
|
|
|
0
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
$Type2Pkg{$oid} = $class; |
85
|
0
|
|
|
|
|
0
|
$Pkg2Type{$class} = $oid; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub new { |
89
|
4
|
|
|
4
|
1
|
6
|
my $self = shift; |
90
|
4
|
|
33
|
|
|
14
|
my $pkg = ref($self) || $self; |
91
|
4
|
50
|
|
|
|
12
|
my $oid = (@_ & 1) ? shift : undef; |
92
|
4
|
|
|
|
|
16
|
my %args = @_; |
93
|
|
|
|
|
|
|
|
94
|
4
|
|
0
|
|
|
10
|
$args{type} ||= $oid || $Pkg2Type{$pkg} || ''; |
|
|
|
33
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
4
|
50
|
|
|
|
25
|
unless ($args{type} =~ /^\d+(?:\.\d+)+$/) { |
97
|
0
|
|
|
|
|
0
|
$args{error} = 'Invalid OID'; |
98
|
0
|
|
|
|
|
0
|
return bless \%args; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
4
|
50
|
33
|
|
|
27
|
if ($pkg eq __PACKAGE__ and exists $Type2Pkg{$args{type}}) { |
102
|
4
|
|
|
|
|
9
|
$pkg = $Type2Pkg{$args{type}}; |
103
|
4
|
50
|
|
|
|
256
|
eval "require $pkg" or die $@; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
4
|
|
|
|
|
13
|
delete $args{error}; |
107
|
|
|
|
|
|
|
|
108
|
4
|
|
|
|
|
16
|
bless(\%args, $pkg)->init; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub from_asn { |
113
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
114
|
0
|
|
|
|
|
0
|
my $asn = shift; |
115
|
0
|
|
0
|
|
|
0
|
my $class = ref($self) || $self; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
0
|
|
|
0
|
if ($class eq __PACKAGE__ and exists $Type2Pkg{$asn->{type}}) { |
118
|
0
|
|
|
|
|
0
|
$class = $Type2Pkg{$asn->{type}}; |
119
|
0
|
0
|
|
|
|
0
|
eval "require $class" or die $@; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
0
|
delete $asn->{error}; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
bless($asn, $class)->init; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub to_asn { |
128
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
129
|
0
|
|
|
|
|
0
|
$self->value; # Ensure value is there |
130
|
0
|
0
|
|
|
|
0
|
delete $self->{critical} unless $self->{critical}; |
131
|
0
|
|
|
|
|
0
|
$self; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub critical { |
135
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
136
|
2
|
50
|
|
|
|
4
|
$self->{critical} = shift if @_; |
137
|
2
|
50
|
|
|
|
23
|
$self->{critical} || 0; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub value { |
141
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
142
|
0
|
0
|
|
|
|
0
|
$self->{value} = shift if @_; |
143
|
|
|
|
|
|
|
$self->{value} || undef |
144
|
0
|
0
|
|
|
|
0
|
} |
145
|
|
|
|
|
|
|
|
146
|
4
|
|
|
4
|
1
|
58
|
sub type { shift->{type} } |
147
|
0
|
|
|
0
|
1
|
|
sub valid { ! exists shift->{error} } |
148
|
0
|
|
|
0
|
1
|
|
sub error { shift->{error} } |
149
|
0
|
|
|
0
|
1
|
|
sub init { shift } |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
__END__ |