line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::LDAP::posixGroup; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23976
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
965
|
use Net::LDAP::Entry; |
|
1
|
|
|
|
|
143402
|
|
|
1
|
|
|
|
|
564
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Net::LDAP::posixGroup - Creates new Net::LDAP::Entry objects for a posixGroup entry. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.0.2 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.0.2'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Net::LDAP::posixGroup; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $foo = Net::LDAP::posixGroup->new({baseDN=>'ou=group,dc=foo'}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#creates a new entry with the minimum requirements |
27
|
|
|
|
|
|
|
my $entry = $foo->create({name=>'vvelox', gid=>'404'}, ['user1', 'user2']); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 FUNCTIONS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 new |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
|
my %args; |
38
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
39
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#returns undef if the baseDN is not set |
43
|
0
|
0
|
|
|
|
|
if (!defined($args{baseDN})) { |
44
|
0
|
|
|
|
|
|
warn('Net-LDAP-postixGroup new:0: "baseDN" is not defined'); |
45
|
0
|
|
|
|
|
|
return undef; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $self={error=>undef, set=>undef, baseDN=>$args{baseDN}}; |
49
|
0
|
|
|
|
|
|
bless $self; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#if it is defined it sets the topless setting to what ever it is |
52
|
0
|
0
|
|
|
|
|
if (defined($args{topless})) { |
53
|
0
|
|
|
|
|
|
$self->{topless}=$args{topless}; |
54
|
|
|
|
|
|
|
}else { |
55
|
0
|
|
|
|
|
|
$self->{topless}=undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 create |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Creates a new Net::LDAP::Entry object. The first value is a |
64
|
|
|
|
|
|
|
hash. See the below for avialble values. The second is a array |
65
|
|
|
|
|
|
|
with the group members. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head3 name |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The group name. This is required. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head3 gid |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The numeric GID of a group. This is required. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head3 description |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
A optional LDAP desciption. This is optional. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head3 primary |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The accepted values are 'cn' and 'gidNumber'. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub create{ |
86
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
87
|
0
|
|
|
|
|
|
my %args; |
88
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
89
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
}; |
91
|
0
|
|
|
|
|
|
my @members; |
92
|
0
|
0
|
|
|
|
|
if (defined($_[2])) { |
93
|
0
|
|
|
|
|
|
@members=@{$_[2]}; |
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#error if name is not defined |
97
|
0
|
0
|
|
|
|
|
if (!defined($args{name})) { |
98
|
0
|
|
|
|
|
|
warn('Net-LDAP-posixGroup create:1: name not defined'); |
99
|
0
|
|
|
|
|
|
$self->{error}=1; |
100
|
0
|
|
|
|
|
|
$self->{errorString}='name not defined'; |
101
|
0
|
|
|
|
|
|
return undef; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#error if name is not defined |
105
|
0
|
0
|
|
|
|
|
if (!defined($args{name})) { |
106
|
0
|
|
|
|
|
|
warn('Net-LDAP-posixGroup create:2: gid not defined'); |
107
|
0
|
|
|
|
|
|
$self->{error}=2; |
108
|
0
|
|
|
|
|
|
$self->{errorString}='gid not defined'; |
109
|
0
|
|
|
|
|
|
return undef; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#sets the primary if it is not defined |
113
|
0
|
0
|
|
|
|
|
if (!defined($args{primary})) { |
114
|
0
|
|
|
|
|
|
$args{primary}='cn'; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#verifies the primary |
118
|
0
|
|
|
|
|
|
my @primary=('gid', 'cn'); |
119
|
0
|
|
|
|
|
|
my $dn=undef; |
120
|
0
|
|
|
|
|
|
my $primaryInt=0; |
121
|
0
|
|
|
|
|
|
while (defined($primary[$primaryInt])) { |
122
|
|
|
|
|
|
|
#when a match is found, use it to begin forming the the DN |
123
|
0
|
0
|
|
|
|
|
if ($args{primary} eq $primary[$primaryInt]) { |
124
|
0
|
|
|
|
|
|
$dn=$args{primary}.'='; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
$primaryInt++; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
#error if none is matched |
130
|
0
|
0
|
|
|
|
|
if (!defined($dn)) { |
131
|
0
|
|
|
|
|
|
warn('Net-LDAP-posixGroup create:3: primary is a invalid value'); |
132
|
0
|
|
|
|
|
|
$self->{error}=3; |
133
|
0
|
|
|
|
|
|
$self->{errorString}='primary is a invalid value'; |
134
|
0
|
|
|
|
|
|
return undef; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#forms the DN if it is using the gidNumber |
138
|
0
|
0
|
|
|
|
|
if ($args{primary} eq 'gidNumber') { |
139
|
0
|
|
|
|
|
|
$dn=$dn.$args{uid}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#forms the DN if it is using the CN |
143
|
0
|
0
|
|
|
|
|
if ($args{primary} eq 'cn') { |
144
|
0
|
|
|
|
|
|
$dn=$dn.$args{name}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#full forms the DN |
148
|
0
|
|
|
|
|
|
$dn=$dn.','.$self->{baseDN}; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#creates a new object |
151
|
0
|
|
|
|
|
|
my $entry = Net::LDAP::Entry->new; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#sets the dn |
154
|
0
|
|
|
|
|
|
$entry->dn($dn); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#adds the various attributes |
157
|
0
|
|
|
|
|
|
$entry->add(objectClass=>['posixGroup', 'top'], |
158
|
|
|
|
|
|
|
gidNumber=>[$args{gid}], cn=>[$args{name}]); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#adds the description if needed |
161
|
0
|
0
|
|
|
|
|
if (defined($args{description})) { |
162
|
0
|
|
|
|
|
|
$entry->add(description=>[$args{description}]); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my $membersInt=0; |
166
|
0
|
|
|
|
|
|
while (defined($members[$membersInt])) { |
167
|
0
|
|
|
|
|
|
$entry->add(memberUid=>[$members[$membersInt]]); |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$membersInt++; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return $entry; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 errorBlank |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
A internal function user for clearing an error. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
#blanks the error flags |
183
|
|
|
|
|
|
|
sub errorBlank{ |
184
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#error handling |
187
|
0
|
|
|
|
|
|
$self->{error}=undef; |
188
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
return 1; |
191
|
|
|
|
|
|
|
}; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 Error Codes |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 0 |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Missing baseDN. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 1 |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
No group name specified. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 2 |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
No GID specified. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head2 3 |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The primary is a invalid value. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 BUGS |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
218
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
219
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 SUPPORT |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
perldoc Net::LDAP::posixGroup |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
You can also look for information at: |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=over 4 |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
L |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
L |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * CPAN Ratings |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
L |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * Search CPAN |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=back |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Copyright 2008 Zane C. Bowers, all rights reserved. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
262
|
|
|
|
|
|
|
under the same terms as Perl itself. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
1; # End of Net::LDAP::posixGroup |