line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::LDAP::LDAPhash; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20756
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
1250
|
use Net::LDAP; |
|
1
|
|
|
|
|
517829
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
86
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
368
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
our @EXPORT = qw(LDAPhash); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(LDAPhash); |
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = (DEFAULT => [qw(LDAPhash)]); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Net::LDAP::LDAPhash - Takes from a search and turns it into a hash. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 1.0.3 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Net::LDAP::LDAPhash; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $ldapconnection = Net::LDAP->new( "127.0.0.1" ) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $bindMessage->bind( "cn=admin,dc=someBase", password=>"password", version=>3 ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $mesg = $ldapconnection->search(scope=>"sub","dc=someBase", filter=>"(objectClass=*)"); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my %foo = LDAPhash($mesg); |
39
|
|
|
|
|
|
|
... |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 EXPORT |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
LDAPhash |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 FUNCTIONS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 LDAPhash ( mesg ) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This takes from a search and turns it into a hash. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The returned has is in the following format. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{DN}{ldap}{attribute}[array of values for this attribute] |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The reason for the {ldap} is to allow for other values and the like to be tagged |
56
|
|
|
|
|
|
|
onto a hash for a DN that are unrelated to LDAP. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This function does not make any attempt to check if the search succedded or not. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub LDAPhash { |
63
|
0
|
|
|
0
|
1
|
|
my $mesg = $_[0]; #the object returned from a LDAP search |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#used for holding the data, before returning it |
66
|
0
|
|
|
|
|
|
my %data; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#builds it |
69
|
0
|
|
|
|
|
|
my $entryinter=0; |
70
|
0
|
|
|
|
|
|
my $max = $mesg->count; |
71
|
0
|
|
|
|
|
|
for ( $entryinter = 0 ; $entryinter < $max ; $entryinter++ ){ |
72
|
0
|
|
|
|
|
|
my $entry = $mesg->entry ( $entryinter ); |
73
|
0
|
|
|
|
|
|
$data{$entry->dn}={ldap=>{dn=>$entry->dn},internal=>{changed=>0}}; |
74
|
|
|
|
|
|
|
#builds a hash of attributes |
75
|
0
|
|
|
|
|
|
foreach my $attr ( $entry->attributes ) { |
76
|
0
|
|
|
|
|
|
$data{$entry->dn}{ldap}{$attr}=[]; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#builds the array of values for the attribute |
79
|
0
|
|
|
|
|
|
my $valueinter=0; |
80
|
0
|
|
|
|
|
|
my @attributes=$entry->get_value($attr); |
81
|
0
|
|
|
|
|
|
while (defined($attributes[$valueinter])){ |
82
|
0
|
|
|
|
|
|
$data{$entry->dn}{ldap}{$attr}[$valueinter]=$attributes[$valueinter]; |
83
|
0
|
|
|
|
|
|
$valueinter++; |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return %data; |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 BUGS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Please report any bugs or the like to vvelox@vvelox.net. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SUPPORT |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
perldoc Net::LDAP::LDAPhash |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright 2011 Zane C. Bowers-Hadley, all rights reserved. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
113
|
|
|
|
|
|
|
under the same terms as Perl itself. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
WIML, #43892, pointed out out that 't/pod-coverage.t' does not exist, but does in the MANIFEST |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; # End of Net::LDAP::LDAPhash |