1 |
dpavlin |
222 |
package A3C::LDAP::Server; |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings; |
5 |
|
|
use Data::Dumper; |
6 |
|
|
|
7 |
|
|
use lib '../lib'; |
8 |
|
|
use Net::LDAP::Constant qw(LDAP_SUCCESS); |
9 |
|
|
use Net::LDAP::Server; |
10 |
|
|
use base 'Net::LDAP::Server'; |
11 |
|
|
use fields qw(); |
12 |
|
|
|
13 |
|
|
use constant RESULT_OK => { |
14 |
|
|
'matchedDN' => '', |
15 |
|
|
'errorMessage' => '', |
16 |
|
|
'resultCode' => LDAP_SUCCESS |
17 |
|
|
}; |
18 |
|
|
|
19 |
|
|
# constructor |
20 |
|
|
sub new { |
21 |
|
|
my ($class, $sock) = @_; |
22 |
|
|
my $self = $class->SUPER::new($sock); |
23 |
|
|
printf "Accepted connection from: %s\n", $sock->peerhost(); |
24 |
|
|
return $self; |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
# the bind operation |
28 |
|
|
sub bind { |
29 |
|
|
my $self = shift; |
30 |
|
|
my $reqData = shift; |
31 |
|
|
print Dumper($reqData); |
32 |
|
|
return RESULT_OK; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
# the search operation |
36 |
|
|
sub search { |
37 |
|
|
my $self = shift; |
38 |
|
|
my $reqData = shift; |
39 |
|
|
print "Searching...\n"; |
40 |
|
|
print Dumper($reqData); |
41 |
|
|
my $base = $reqData->{'baseObject'}; |
42 |
|
|
|
43 |
|
|
my @entries; |
44 |
|
|
if ($reqData->{'scope'}) { |
45 |
|
|
|
46 |
|
|
} |
47 |
|
|
warn ">> ",Dumper( @entries ); |
48 |
|
|
return RESULT_OK, @entries; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
# the rest of the operations will return an "unwilling to perform" |
52 |
|
|
|
53 |
|
|
1; |